Tools.h++ Manual

104011 Tandem Computers Incorporated 8-1
VirtualStreams 8
The “iostream” facility that comes with every C++ compiler is a resource that
is familiar to every C++ programmer. Among its advantages are type safe
insertion and extraction into and out of streams and extensibility to new types.
Furthermore, the source and sink of the bytes of the stream are set by another
class (
streambuf
) and are completely transparent to the user of the streams.
But it suffers from a number of limitations. The biggest is its limited
formatting abilities: if you insert, say, a double into an
ostream
, you have very
little say over what format is to be used. For example, there is no type-safe
way to insert it as binary.
Another limitation of iostreams is their assumption that all byte sources and
sinks can fit into the
streambuf
model. For many protocols (for example,
XDR), the format is intrinsically wedded to the byte stream and cannot be
separated.