本文介绍了谁构建/设计C ++的IOStreams,它仍然会被认为精心设计的今天的标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,似乎我要求主观意见,但这不是我的后续。我很乐意听到这个主题的一些基本理由。

First off, it may seem that I'm asking for subjective opinions, but that's not what I'm after. I'd love to hear some well-grounded arguments on this topic.

深入了解现代流/序列化框架应该如何设计,我最近得到了一本书的副本提供。我想如果IOStreams设计不好,它不会把它放到C ++标准库中。

In the hope of getting some insight into how a modern streams / serialization framework ought to be designed, I recently got myself a copy of the book Standard C++ IOStreams and Locales by Angelika Langer and Klaus Kreft. I figured that if IOStreams wasn't well-designed, it wouldn't have made it into the C++ standard library in the first place.

在阅读了各种部分后这本书,我开始有疑问,如果IOStreams可以比较eg从整体架构的角度来看STL。阅读例如,了解进入STL的一些设计决策。

After having read various parts of this book, I am starting to have doubts if IOStreams can compare to e.g. the STL from an overall architectural point-of-view. Read e.g. this interview with Alexander Stepanov (the STL's "inventor") to learn about some design decisions that went into the STL.

特别令人吃惊的是


  • 似乎不知道谁负责IOStreams的整体设计(我想读一些关于这个背景信息,有谁知道很好的资源吗?);

  • It seems to be unknown who was responsible for IOStreams' overall design (I'd love to read some background information about this — does anyone know good resources?);

一旦你深入IOStreams的直接表面,例如如果你想扩展IOStreams与你自己的类,你得到一个相当隐蔽和混淆的成员函数名称的接口,例如。 getloc / imbue uflow / underflow snextc / sbumpc / sgetc / sgetn pbase / pptr epptr (可能还有更糟的例子)。这使得很难理解整体设计以及单个部件如何协作。

Once you delve beneath the immediate surface of IOStreams, e.g. if you want to extend IOStreams with your own classes, you get to an interface with fairly cryptic and confusing member function names, e.g. getloc/imbue, uflow/underflow, snextc/sbumpc/sgetc/sgetn, pbase/pptr/epptr (and there's probably even worse examples). This makes it so much harder to understand the overall design and how the single parts co-operate. Even the book I mentioned above doesn't help that much (IMHO).

因此我的问题:

如果你必须根据今天的软件工程标准实际上 是这些的任何一般协议),C ++的IOStreams仍然被认为设计良好? (我不想从通常被认为过时的东西改善我的软件设计技能。)

If you had to judge by today's software engineering standards (if there actually is any general agreement on these), would C++'s IOStreams still be considered well-designed? (I wouldn't want to improve my software design skills from something that's generally considered outdated.)

推荐答案

找到自己的方式进入标准: auto_ptr 向量< bool> valarray export ,这里仅列出几个。所以我不会采取IOStreams的存在必然作为质量设计的标志。

Several ill-conceived ideas found their way into the standard: auto_ptr, vector<bool>, valarray and export, just to name a few. So I wouldn't take the presence of IOStreams necessarily as a sign of quality design.

IOStreams有一个方格的历史。它们实际上是对早期流库的重做,但是在当今许多C ++成语不存在的时候创作,所以设计师没有后见之明的好处。随着时间的推移,一个明显的问题是,几乎不可能像C的stdio一样有效地实现IOStreams,因为虚拟函数的大量使用和转发到内部缓冲区对象甚至最细粒度,以及由于一些不可克服的陌生在地域定义和实施的方式。我的记忆是相当模糊,我承认;我记得它是几年前对comp.lang.c ++进行激烈辩论的主题。

IOStreams have a checkered history. They are actually a reworking of an earlier streams library, but were authored at a time when many of today's C++ idioms didn't exist, so the designers didn't have the benefit of hindsight. One issue that only became apparent over time was that it is almost impossible to implement IOStreams as efficiently as C's stdio, due to the copious use of virtual functions and forwarding to internal buffer objects at even the finest granularity, and also thanks to some inscrutable strangeness in the way locales are defined and implemented. My memory of this is quite fuzzy, I'll admit; I remember it being the subject of intense debate some years ago, on comp.lang.c++.moderated.

这篇关于谁构建/设计C ++的IOStreams,它仍然会被认为精心设计的今天的标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 20:46