From bd16c171e6b67ec31df4a8497976105f1d94ab02 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 5 Nov 2001 16:43:43 +0000 Subject: [PATCH] fixed lexical cast g++ sstream problem [SVN r11592] --- include/boost/lexical_cast.hpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 5096e1b..c36a14a 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -13,11 +13,18 @@ // where: tested with MSVC 6.0, BCC 5.5, and g++ 2.91 #include -# ifndef BOOST_NO_STRINGSTREAM -# include -# else -# include + +// The GNU sstream implementation is broken for the purposes of lexical cast. +# if defined(BOOST_NO_STRINGSTREAM) || (defined(__GNUC__) && !defined(__STL_USE_NEW_IOSTREAMS) || defined(__APPLE_CC__)) +# define BOOST_LEXICAL_CAST_USE_STRSTREAM # endif + +#ifdef BOOST_LEXICAL_CAST_USE_STRSTREAM +# include +#else +# include +#endif + #include namespace boost @@ -39,10 +46,10 @@ namespace boost template Target lexical_cast(Source arg) { -# ifndef BOOST_NO_STRINGSTREAM - std::stringstream interpreter; -# else +# ifdef BOOST_LEXICAL_CAST_USE_STRSTREAM std::strstream interpreter; // for out-of-the-box g++ 2.95.2 +# else + std::stringstream interpreter; # endif Target result; @@ -64,4 +71,8 @@ namespace boost // // This software is provided "as is" without express or implied warranty. +#ifdef BOOST_LEXICAL_CAST_USE_STRSTREAM +# undef BOOST_LEXICAL_CAST_USE_STRSTREAM +#endif + #endif