VirtualBox

source: vbox/trunk/src/libs/boost-1.37.0/boost/exception/to_string.hpp@ 44888

最後變更 在這個檔案從44888是 16204,由 vboxsync 提交於 16 年 前

export the boost stuff required for Main

檔案大小: 1.7 KB
 
1//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
2
3//Distributed under the Boost Software License, Version 1.0. (See accompanying
4//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef UUID_7E48761AD92811DC9011477D56D89593
7#define UUID_7E48761AD92811DC9011477D56D89593
8
9#include <boost/utility/enable_if.hpp>
10#include <boost/exception/detail/is_output_streamable.hpp>
11#include <sstream>
12
13namespace
14boost
15 {
16 namespace
17 to_string_detail
18 {
19 template <class T>
20 typename disable_if<is_output_streamable<T>,char>::type to_string( T const & );
21
22 template <class,bool IsOutputStreamable>
23 struct has_to_string_impl;
24
25 template <class T>
26 struct
27 has_to_string_impl<T,true>
28 {
29 enum e { value=1 };
30 };
31
32 template <class T>
33 struct
34 has_to_string_impl<T,false>
35 {
36 static T const & f();
37 enum e { value=1!=sizeof(to_string(f())) };
38 };
39 }
40
41 template <class T>
42 inline
43 typename enable_if<is_output_streamable<T>,std::string>::type
44 to_string( T const & x )
45 {
46 std::ostringstream out;
47 out << x;
48 return out.str();
49 }
50
51 template <class T>
52 struct
53 has_to_string
54 {
55 enum e { value=to_string_detail::has_to_string_impl<T,is_output_streamable<T>::value>::value };
56 };
57
58 template <class T,class U>
59 inline
60 std::string
61 to_string( std::pair<T,U> const & x )
62 {
63 return std::string("(") + to_string(x.first) + ',' + to_string(x.second) + ')';
64 }
65
66 inline
67 std::string
68 to_string( std::exception const & x )
69 {
70 return x.what();
71 }
72 }
73
74#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette