Recent strstream regression: reversion needed?

Jonathan Wakely cow@compsoc.man.ac.uk
Thu Jun 6 03:26:00 GMT 2002


On Thu, Jun 06, 2002 at 02:52:32AM -0400, Phil Edwards wrote:

> On Wed, Jun 05, 2002 at 01:25:04AM -0700, Benjamin Kosnik wrote:
> > I'm convinced that removing the strstream code and just typedefing
> > strstream to stringstream<char>, istrstream to istringstream<char>,
> > ostrstream to ostringstream<char>, etc,  would work much better than the
> > present solution. I think it was discussed but I'm not quite sure why
> > the current solution is in place instead.
> 
> We can probably use private inheritence (the famous "is-implemented-in-terms-of"
> relation) to do it, e.g., "class strstream : private stringstream<char>"
> but I don't think we can get away with a typedef.

A typedef definitely won't do
stringstream has no freeze(bool) member
its str() returns basic_string, not char* as strstream's must do
ostringstreams have no pcount() member

There's also the issue of the extra ctor for istrstreams, that takes an
existing char buffer and initialises the strstreambuf with it (whereas the
istringstream ctor takes a copy to initialise the stringstreambuf). This
is useful for parsing an existing char buffer without taking a copy of it.
This is the one advantage of strstreams over stringstreams that I know of.

> I say this only because I've seen calls to a "freeze" strstream member
> function.  (I don't know what that function does, and don't really care,
> because I've never used strstreams and think they should die as soon
> as possible.)

Maybe, but I think until it's officially removed from the standard (not
just deprecated) it has to be in libstdc++. Anyone using 2.95 can't use
stringstreams and is forced to use strstreams (with all the unfreezing
crap that goes with them). We use them all over the place where I work,
and switching to 3.x will be much harder if strstreams aren't there,
or don't work correctly.
I know there's an sstream header for 2.95.3, but for some reason it
doesn't seem to be included in FreeBSD's 2.95.3 so we're stuck with
strstreams. Please don't point me at the "sstream for 2.95.2" header at
http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00700/sstream because I've
tried it and it gives warnings when compiled with -Wall, requires rtti
(this can be changed by using static_cast not dynamic_cast) and worst of
all, it plain don't work.

How about just leaving strstream so it leaks a small amount occasionally?
It's always hard to use them without causing leaks anyway  ;)

jon



-- 
"A foolish consistency is the hobgoblin of little minds..."
	- Ralph Waldo Emerson



More information about the Libstdc++ mailing list