sstream.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=============================================================================
  2. Copyright (c) 2003 Martin Wille
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #include <boost/config.hpp>
  9. ///////////////////////////////////////////////////////////////////////////
  10. // workaround for prestandard support of stringstreams
  11. //
  12. // * defines sstream_t for the string stream type
  13. // * defines std::string getstring(sstream_t &);
  14. //
  15. #ifdef BOOST_NO_STRINGSTREAM
  16. # include <strstream>
  17. typedef strstream sstream_t;
  18. std::string
  19. getstring(std::strstream& ss)
  20. {
  21. ss << ends;
  22. std::string rval = ss.str();
  23. ss.freeze(false);
  24. return rval;
  25. }
  26. #else
  27. # include <sstream>
  28. typedef std::stringstream sstream_t;
  29. std::string
  30. getstring(std::stringstream &ss)
  31. {
  32. return ss.str();
  33. }
  34. #endif
  35. void use_getstring_to_avoid_compiler_warnings_about_unused_functions()
  36. {
  37. sstream_t ss;
  38. getstring(ss);
  39. if(!ss) { // to be not recursive on all control paths
  40. use_getstring_to_avoid_compiler_warnings_about_unused_functions();
  41. }
  42. }