S
sb
I think streams are nice, but what do you do when you have to write to
or, even worse, read from a FILE*, for example a UNIX stream?
C++ streams can not be created from FILE*'s or have them attached.
Today, a C++ programmer has to decide beforehand whether he wants to
use C or C++ I/O. Suppose you choose C++ streams and write all of the
"operator>>" code for your objects. If you later decide to read the
same objects from a UNIX pipe, you'll have to rewrite and re-debug
much of that code.
Since C++ was aiming for seamless interoperability with C, wouldn't it
have been easier to make its file stream a shallow wrapper around
FILE*? It already has the necessary buffering functionality. Or at
least specialize the character streams to be such bufferless wrappers
around FILE* ?
On a more positive note, I haven't used them yet, but it looks like
STLport provides such shallow stream wrappers as an option.
or, even worse, read from a FILE*, for example a UNIX stream?
C++ streams can not be created from FILE*'s or have them attached.
Today, a C++ programmer has to decide beforehand whether he wants to
use C or C++ I/O. Suppose you choose C++ streams and write all of the
"operator>>" code for your objects. If you later decide to read the
same objects from a UNIX pipe, you'll have to rewrite and re-debug
much of that code.
Since C++ was aiming for seamless interoperability with C, wouldn't it
have been easier to make its file stream a shallow wrapper around
FILE*? It already has the necessary buffering functionality. Or at
least specialize the character streams to be such bufferless wrappers
around FILE* ?
On a more positive note, I haven't used them yet, but it looks like
STLport provides such shallow stream wrappers as an option.