[Insight-developers] itk::OStringStream
Brad King
brad . king at kitware . com
Fri, 19 Jul 2002 15:40:39 -0400 (EDT)
Hello, all:
Recently I added a nightly build using gcc 3.1, but it generates over
30000 warnings. Many of them are due to the use of the <strstream>
header. The old std::ostrstream class has been deprecated, and should not
be used in new code. However, the new std::ostringstream class isn't
available everywhere.
To get around this problem, I've added a class called "OStringStream" to
the itk namespace. It is std::ostringstream when available. Otherwise,
it is a wrapper around std::ostrstream that makes it behave like the new
std::ostringstream. The new version is much easier to use than the old
ostrstream. We no longer need to worry about memory leaks
(rdbuf()->freeze(0)) or about ending the string with std::ends before
using it.
A typical use of OStringStream looks like this:
OStringStream message;
message << "Position: " << position; // don't need std::ends
std::string msg = message.str(); // str() returns std::string
I have changed all of ITK in CVS to use the new OStringStream class.
Please use this class in all future code in ITK.
Thanks,
-Brad