In article <42***********************@ptn-nntp-reader03.plus.net>,
"Aaron Gray" <aa********@gmail.com> wrote:
Hi,
I have an application that uses 'strstream' in just under half its .cc
files, about 10 files.
What is the replacement for 'strstream' ?
What are my options for replacing it ?
Many thanks in advance,
Aaron
Try one of:
ostringstream
istringstream
stringstream
which are all in the header <sstream>.
The chances aren't bad that a simple find/replace will get you going
without a hitch. The main difference is that the stringstream family
doesn't expose its internal buffer and is thus less susceptible to
memory leaks.
strstream is deprecated because it is memory leak prone. That is not to
say that correct usage of it might result in a memory leak, just that it
is so easy to misuse it, resulting in a memory leak.
That being said, strstream fulfills a role that has not yet been
replaced in the std::lib: The ability to specify the buffer which the
read/write interacts with. If you need to specify the buffer (say for
performance reasons or whatever), the stringstream family will not do it
for you. There is no alternative in the std::lib for this application.
Although strstream has been deprecated for nearly a decade, I don't
anticipate removing it from C++0X because of the lack of covering the
above mentioned functionality. I have no doubt that a better facility
could be designed for this functionality, but no one to date has
proposed anything.
-Howard