]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/exception/to_string.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
483aed9b15d3dfb1d804e07b58de258ab6fed994
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / exception / to_string.hpp
1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.\r
2 \r
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying\r
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
5 \r
6 #ifndef UUID_7E48761AD92811DC9011477D56D89593\r
7 #define UUID_7E48761AD92811DC9011477D56D89593\r
8 #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)\r
9 #pragma GCC system_header\r
10 #endif\r
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)\r
12 #pragma warning(push,1)\r
13 #endif\r
14 \r
15 #include <boost/utility/enable_if.hpp>\r
16 #include <boost/exception/detail/is_output_streamable.hpp>\r
17 #include <sstream>\r
18 \r
19 namespace\r
20 boost\r
21     {\r
22     namespace\r
23     to_string_detail\r
24         {\r
25         template <class T>\r
26         typename disable_if<is_output_streamable<T>,char>::type to_string( T const & );\r
27 \r
28         template <class,bool IsOutputStreamable>\r
29         struct has_to_string_impl;\r
30 \r
31         template <class T>\r
32         struct\r
33         has_to_string_impl<T,true>\r
34             {\r
35             enum e { value=1 };\r
36             };\r
37 \r
38         template <class T>\r
39         struct\r
40         has_to_string_impl<T,false>\r
41             {\r
42             static T const & f();\r
43             enum e { value=1!=sizeof(to_string(f())) };\r
44             };\r
45         }\r
46 \r
47     template <class T>\r
48     inline\r
49     typename enable_if<is_output_streamable<T>,std::string>::type\r
50     to_string( T const & x )\r
51         {\r
52         std::ostringstream out;\r
53         out << x;\r
54         return out.str();\r
55         }\r
56 \r
57     template <class T>\r
58     struct\r
59     has_to_string\r
60         {\r
61         enum e { value=to_string_detail::has_to_string_impl<T,is_output_streamable<T>::value>::value };\r
62         };\r
63 \r
64     template <class T,class U>\r
65     inline\r
66     std::string\r
67     to_string( std::pair<T,U> const & x )\r
68         {\r
69         return std::string("(") + to_string(x.first) + ',' + to_string(x.second) + ')';\r
70         }\r
71 \r
72     inline\r
73     std::string\r
74     to_string( std::exception const & x )\r
75         {\r
76         return x.what();\r
77         }\r
78     }\r
79 \r
80 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)\r
81 #pragma warning(pop)\r
82 #endif\r
83 #endif\r