]> git.lyx.org Git - features.git/blob - boost/boost/exception/detail/type_info.hpp
60709a1f6c08991262c371b7eb9d0085bec401c0
[features.git] / boost / boost / exception / detail / type_info.hpp
1 //Copyright (c) 2006-2009 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_C3E1741C754311DDB2834CCA55D89593
7 #define UUID_C3E1741C754311DDB2834CCA55D89593
8 #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
9 #pragma GCC system_header
10 #endif
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
12 #pragma warning(push,1)
13 #endif
14
15 #include <boost/detail/sp_typeinfo.hpp>
16 #include <boost/current_function.hpp>
17 #include <boost/config.hpp>
18
19 namespace
20 boost
21     {
22     template <class T>
23     inline
24     char const *
25     tag_type_name()
26         {
27 #ifdef BOOST_NO_TYPEID
28         return BOOST_CURRENT_FUNCTION;
29 #else
30         return typeid(T*).name();
31 #endif
32         }
33
34     template <class T>
35     inline
36     char const *
37     type_name()
38         {
39 #ifdef BOOST_NO_TYPEID
40         return BOOST_CURRENT_FUNCTION;
41 #else
42         return typeid(T).name();
43 #endif
44         }
45
46     namespace
47     exception_detail
48         {
49         struct
50         type_info_
51             {
52             detail::sp_typeinfo const & type_;
53
54             explicit
55             type_info_( detail::sp_typeinfo const & type ):
56                 type_(type)
57                 {
58                 }
59
60             friend
61             bool
62             operator<( type_info_ const & a, type_info_ const & b )
63                 {
64                 return 0!=(a.type_.before(b.type_));
65                 }
66             };
67         }
68     }
69
70 #define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T))
71
72 #ifndef BOOST_NO_RTTI
73 #define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x))
74 #endif
75
76 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
77 #pragma warning(pop)
78 #endif
79 #endif