Boost logo

Boost :

From: Craig Rodrigues (rodrigc_at_[hidden])
Date: 2002-03-04 23:13:14


Hi,

any_test.cpp produces the following warning in gcc 3.1:

In file included from /u0/test/gcc3.1/include/g++-v3/backward/strstream:51,
                 from test.hpp:11,
                 from any_test.cpp:11:
/u0/test/gcc3.1/include/g++-v3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.

Since GCC 3.0 and higher include sstream, is this patch OK?

Index: test.hpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/any/test.hpp,v
retrieving revision 1.4
diff -u -u -r1.4 test.hpp
--- test.hpp 8 Aug 2001 11:15:09 -0000 1.4
+++ test.hpp 5 Mar 2002 04:10:44 -0000
@@ -8,7 +8,7 @@
 
 #include <exception>
 #include <iostream>
-#include <strstream> // for out-of-the-box g++
+#include <sstream>
 #include <string>
 
 namespace test // test tuple comprises name and nullary function (object)
@@ -245,13 +245,12 @@
                 {
                     unsigned long allocated = allocations::instance().allocated();
                     unsigned long deallocated = allocations::instance().deallocated();
- ostrstream report;
+ ostringstream report;
                     report << "new/delete ("
                            << allocated << " allocated, "
                            << deallocated << " deallocated)"
                            << ends;
- const char * text = report.str();
- report.freeze(false);
+ string text = report.str();
                     throw failure(text);
                 }
 

-- 
Craig Rodrigues        
http://www.gis.net/~craigr    
rodrigc_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk