Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:47

0001 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
0002 
0003 //Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_EXCEPTION_7E48761AD92811DC9011477D56D89593
0007 #define BOOST_EXCEPTION_7E48761AD92811DC9011477D56D89593
0008 
0009 #include <boost/core/enable_if.hpp>
0010 #include <boost/exception/detail/is_output_streamable.hpp>
0011 #include <sstream>
0012 
0013 #ifndef BOOST_EXCEPTION_ENABLE_WARNINGS
0014 #if __GNUC__*100+__GNUC_MINOR__>301
0015 #pragma GCC system_header
0016 #endif
0017 #ifdef __clang__
0018 #pragma clang system_header
0019 #endif
0020 #ifdef _MSC_VER
0021 #pragma warning(push,1)
0022 #endif
0023 #endif
0024 
0025 namespace
0026 boost
0027     {
0028     template <class T,class U>
0029     std::string to_string( std::pair<T,U> const & );
0030     std::string to_string( std::exception const & );
0031 
0032     namespace
0033     to_string_detail
0034         {
0035         template <class T>
0036         typename disable_if<is_output_streamable<T>,char>::type to_string( T const & );
0037         using boost::to_string;
0038 
0039         template <class,bool IsOutputStreamable>
0040         struct has_to_string_impl;
0041 
0042         template <class T>
0043         struct
0044         has_to_string_impl<T,true>
0045             {
0046             enum e { value=1 };
0047             };
0048 
0049         template <class T>
0050         struct
0051         has_to_string_impl<T,false>
0052             {
0053             static T const & f();
0054             enum e { value=1!=sizeof(to_string(f())) };
0055             };
0056         }
0057 
0058     template <class T>
0059     inline
0060     typename enable_if<is_output_streamable<T>,std::string>::type
0061     to_string( T const & x )
0062         {
0063         std::ostringstream out;
0064         out << x;
0065         return out.str();
0066         }
0067 
0068     template <class T>
0069     struct
0070     has_to_string
0071         {
0072         enum e { value=to_string_detail::has_to_string_impl<T,is_output_streamable<T>::value>::value };
0073         };
0074 
0075     template <class T,class U>
0076     inline
0077     std::string
0078     to_string( std::pair<T,U> const & x )
0079         {
0080         return std::string("(") + to_string(x.first) + ',' + to_string(x.second) + ')';
0081         }
0082 
0083     inline
0084     std::string
0085     to_string( std::exception const & x )
0086         {
0087         return x.what();
0088         }
0089     }
0090 
0091 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
0092 #pragma warning(pop)
0093 #endif
0094 #endif