Chris@16: //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. Chris@16: Chris@16: //Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef UUID_7E48761AD92811DC9011477D56D89593 Chris@16: #define UUID_7E48761AD92811DC9011477D56D89593 Chris@16: #if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Chris@16: #pragma GCC system_header Chris@16: #endif Chris@16: #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Chris@16: #pragma warning(push,1) Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace Chris@16: boost Chris@16: { Chris@16: template Chris@16: std::string to_string( std::pair const & ); Chris@16: std::string to_string( std::exception const & ); Chris@16: Chris@16: namespace Chris@16: to_string_detail Chris@16: { Chris@16: template Chris@16: typename disable_if,char>::type to_string( T const & ); Chris@16: using boost::to_string; Chris@16: Chris@16: template Chris@16: struct has_to_string_impl; Chris@16: Chris@16: template Chris@16: struct Chris@16: has_to_string_impl Chris@16: { Chris@16: enum e { value=1 }; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct Chris@16: has_to_string_impl Chris@16: { Chris@16: static T const & f(); Chris@16: enum e { value=1!=sizeof(to_string(f())) }; Chris@16: }; Chris@16: } Chris@16: Chris@16: template Chris@16: inline Chris@16: typename enable_if,std::string>::type Chris@16: to_string( T const & x ) Chris@16: { Chris@16: std::ostringstream out; Chris@16: out << x; Chris@16: return out.str(); Chris@16: } Chris@16: Chris@16: template Chris@16: struct Chris@16: has_to_string Chris@16: { Chris@16: enum e { value=to_string_detail::has_to_string_impl::value>::value }; Chris@16: }; Chris@16: Chris@16: template Chris@16: inline Chris@16: std::string Chris@16: to_string( std::pair const & x ) Chris@16: { Chris@16: return std::string("(") + to_string(x.first) + ',' + to_string(x.second) + ')'; Chris@16: } Chris@16: Chris@16: inline Chris@16: std::string Chris@16: to_string( std::exception const & x ) Chris@16: { Chris@16: return x.what(); Chris@16: } Chris@16: } Chris@16: Chris@16: #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: #endif