Name

DEFECT_OLD_STRINGSTREAM


Affected Systems-Compilers

Systems: all

Compilers: GNU C++ 2.7, SGI MipsPro 7.1nx


Description

The class strstream defined in the header file strstream or strstream.h has been deprecated by C++ Standardization committee. Its intended replacement is the class stringstream defined in the header file sstream. Most C++ compilers lack this new class, however. For all practical purposes, the two classes are the same, so strstream can be preprocessed to stand in for stringstream.


Work-Around

#if defined(DEFECT_OLD_STRINGSTREAM)

#include <strstream.h>

#define ostringstream ostrstream // Avoid having two types where only one is required

#else // Standard C++

#include <sstream>

#endif

string result ;

ostringstream type_string ;

type_string << "some text" ;

#if defined(DEFECT_GCC27_STRINGSTREAM_STR)

type_stream << '\0' ; \\ Manually null-terminate the stringstream

result = string(type_stream.str()) ;

#else // Standard C++

result = type_stream.str() ;

#endif