1#ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED
2#define BOOST_CORE_TYPEINFO_HPP_INCLUDED
3
4// MS compatible compilers support #pragma once
5
6#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7# pragma once
8#endif
9
10// core::typeinfo, BOOST_CORE_TYPEID
11//
12// Copyright 2007, 2014 Peter Dimov
13//
14// Distributed under the Boost Software License, Version 1.0.
15// See accompanying file LICENSE_1_0.txt or copy at
16// http://www.boost.org/LICENSE_1_0.txt)
17
18#include <boost/config.hpp>
19
20#if defined( BOOST_NO_TYPEID )
21
22#include <boost/current_function.hpp>
23#include <functional>
24
25namespace boost
26{
27
28namespace core
29{
30
31class typeinfo
32{
33private:
34
35 typeinfo( typeinfo const& );
36 typeinfo& operator=( typeinfo const& );
37
38 char const * name_;
39
40public:
41
42 explicit typeinfo( char const * name ): name_( name )
43 {
44 }
45
46 bool operator==( typeinfo const& rhs ) const
47 {
48 return this == &rhs;
49 }
50
51 bool operator!=( typeinfo const& rhs ) const
52 {
53 return this != &rhs;
54 }
55
56 bool before( typeinfo const& rhs ) const
57 {
58 return std::less< typeinfo const* >()( this, &rhs );
59 }
60
61 char const* name() const
62 {
63 return name_;
64 }
65};
66
67inline char const * demangled_name( core::typeinfo const & ti )
68{
69 return ti.name();
70}
71
72} // namespace core
73
74namespace detail
75{
76
77template<class T> struct core_typeid_
78{
79 static boost::core::typeinfo ti_;
80
81 static char const * name()
82 {
83 return BOOST_CURRENT_FUNCTION;
84 }
85};
86
87#if defined(__SUNPRO_CC)
88// see #4199, the Sun Studio compiler gets confused about static initialization
89// constructor arguments. But an assignment works just fine.
90template<class T> boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name();
91#else
92template<class T> boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name());
93#endif
94
95template<class T> struct core_typeid_< T & >: core_typeid_< T >
96{
97};
98
99template<class T> struct core_typeid_< T const >: core_typeid_< T >
100{
101};
102
103template<class T> struct core_typeid_< T volatile >: core_typeid_< T >
104{
105};
106
107template<class T> struct core_typeid_< T const volatile >: core_typeid_< T >
108{
109};
110
111} // namespace detail
112
113} // namespace boost
114
115#define BOOST_CORE_TYPEID(T) (boost::detail::core_typeid_<T>::ti_)
116
117#else
118
119#include <boost/core/demangle.hpp>
120#include <typeinfo>
121
122namespace boost
123{
124
125namespace core
126{
127
128#if defined( BOOST_NO_STD_TYPEINFO )
129
130typedef ::type_info typeinfo;
131
132#else
133
134typedef std::type_info typeinfo;
135
136#endif
137
138inline std::string demangled_name( core::typeinfo const & ti )
139{
140 return core::demangle( name: ti.name() );
141}
142
143} // namespace core
144
145} // namespace boost
146
147#define BOOST_CORE_TYPEID(T) typeid(T)
148
149#endif
150
151#endif // #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED
152

source code of boost/boost/core/typeinfo.hpp