[lug] OT: C++ strstreams?

Tkil tkil at scrye.com
Thu Apr 11 16:49:31 MDT 2002


>>>>> "Scott" == Scott A Herod <herod at interact-tv.com> writes:

Scott> Quick question: my reference book says that strstreams
Scott> are deprecated.  True?  

a quick web search for them seems to agree.  my library book is at
home, otherwise i'd check it there.  (bummer about the actual standard
not being freely available on the web, no?)

Scott> Then what is the replacement?

stringstreams, which are specializations of basic_stringstream<>
template classes, all declared in the <sstream> header file.

i can't find a rationale for their deprecation offhand.  if you do
happen to have a copy of the standard handy, a note in the
<backward/strstream.h> header file (from gcc-3.0.4) has this to say:

   // WARNING: The classes defined in this header are DEPRECATED.  This
   // header is defined in section D.7.1 of the C++ standard, and it
   // MAY BE REMOVED in a future standard revision.  You should use the
   // header <sstream> instead.

inferring from various other posts, it seems that the two major
reasons for the switch were:

1. strstreams used "char *" arrays; stringstreams use actual c++
   strings.

2. ownership of the storage is much more precisely handled in the new
   classes.  since this changes semantics, you don't want to use the
   same class name...

these might be totally off base, however.  someone with the c++
standard care to verify?

t.



More information about the LUG mailing list