Fixes for VS 2008
[dyninst.git] / external / boost / exception / detail / type_info.hpp
1 //Copyright (c) 2006-2008 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_C3E1741C754311DDB2834CCA55D89593\r
7 #define UUID_C3E1741C754311DDB2834CCA55D89593\r
8 \r
9 #include <boost/detail/sp_typeinfo.hpp>\r
10 #include <boost/current_function.hpp>\r
11 \r
12 namespace\r
13 boost\r
14     {\r
15     template <class T>\r
16     inline\r
17     char const *\r
18     tag_type_name()\r
19         {\r
20 #ifdef BOOST_NO_TYPEID\r
21         return BOOST_CURRENT_FUNCTION;\r
22 #else\r
23         return typeid(T*).name();\r
24 #endif\r
25         }\r
26 \r
27     template <class T>\r
28     inline\r
29     char const *\r
30     type_name()\r
31         {\r
32 #ifdef BOOST_NO_TYPEID\r
33         return BOOST_CURRENT_FUNCTION;\r
34 #else\r
35         return typeid(T).name();\r
36 #endif\r
37         }\r
38 \r
39     namespace\r
40     exception_detail\r
41         {\r
42 #ifdef BOOST_NO_TYPEID\r
43         struct\r
44         type_info_\r
45             {\r
46             detail::sp_typeinfo type_;\r
47             char const * name_;\r
48 \r
49             explicit\r
50             type_info_( detail::sp_typeinfo type, char const * name ):\r
51                 type_(type),\r
52                 name_(name)\r
53                 {\r
54                 }\r
55 \r
56             friend\r
57             bool\r
58             operator==( type_info_ const & a, type_info_ const & b )\r
59                 {\r
60                 return a.type_==b.type_;\r
61                 }\r
62 \r
63             friend\r
64             bool\r
65             operator<( type_info_ const & a, type_info_ const & b )\r
66                 {\r
67                 return a.type_<b.type_;\r
68                 }\r
69 \r
70             char const *\r
71             name() const\r
72                 {\r
73                 return name_;\r
74                 }\r
75             };\r
76 #else\r
77         struct\r
78         type_info_\r
79             {\r
80             detail::sp_typeinfo const * type_;\r
81 \r
82             explicit\r
83             type_info_( detail::sp_typeinfo const & type ):\r
84                 type_(&type)\r
85                 {\r
86                 }\r
87 \r
88             type_info_( detail::sp_typeinfo const & type, char const * ):\r
89                 type_(&type)\r
90                 {\r
91                 }\r
92 \r
93             friend\r
94             bool\r
95             operator==( type_info_ const & a, type_info_ const & b )\r
96                 {\r
97                 return (*a.type_)==(*b.type_);\r
98                 }\r
99 \r
100             friend\r
101             bool\r
102             operator<( type_info_ const & a, type_info_ const & b )\r
103                 {\r
104                 return 0!=(a.type_->before(*b.type_));\r
105                 }\r
106 \r
107             char const *\r
108             name() const\r
109                 {\r
110                 return type_->name();\r
111                 }\r
112             };\r
113 #endif\r
114 \r
115         inline\r
116         bool\r
117         operator!=( type_info_ const & a, type_info_ const & b )\r
118             {\r
119             return !(a==b);\r
120             }\r
121         }\r
122     }\r
123 \r
124 #define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T),::boost::tag_type_name<T>())\r
125 \r
126 #ifndef BOOST_NO_RTTI\r
127 #define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x))\r
128 #endif\r
129 \r
130 #endif\r