Topic: Proposal for changes to the iostream library:
Author: linguist@m-net.arbornet.org (Rich Paul)
Date: 27 Nov 1994 20:07:47 GMT Raw View
I've got a suggestion some changes to the iostreams library.
Specificly, I dislike having instances of filebuf within an ifstream
or ofstream object. I understand that the members of ?fstream need to
have access to specific functions of filebuf that are not in streambase,
and that casting rdbuf() all over the code would be inelegant, but per-
haps I have a compromise ...
The members of fstream that require a filebuf rather than a stream-
buf seem mostly to be wrappers around member-functions of the filebuf
itself ... thus if one removed the filebuf instance 'buf' from the
fstreambase, made sure that only filebuf and it's descendants could be
assigned to bp in an fstream, and added
streambuf *ostream::operator -> (void) { return bp; };
streambuf *ofstream::operator -> (void) { return bp; };
the following would work just fine ...
ofstream File ("file,name.here");
File->seekg ( PosYouWant );
File << Whatever;
This would make derivation from ostream or ofstream much easier.
----------
On the same note, although I don't know all of the implecations of this,
or how difficult it would be, but virtual pointer data members seem like
a nice idea to me ... for example, what if you could do this?
class ios {
...
private:
virtual streabuf *bp;
};
class fstream: public ios {
private:
filebuf *bp;
};
class streambuf { ... };
class filebuf:public streambuf { ... };
class newfilebuf:public filebuf { ... };
and be allowed to assign filebuf or newfilebuf to fstream::bp, but not
streambuf?
--------------------------------------------------------------
Support the Liberatarians | Rich Paul
before they're outlawed! | linguist@m-net.arbornet.org
--------------------------------------------------------------