1 #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED
2 #define BOOST_CORE_TYPEINFO_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 // core::typeinfo, BOOST_CORE_TYPEID
12 // Copyright 2007, 2014 Peter Dimov
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)
18 #include <boost/config.hpp>
20 #if defined( BOOST_NO_TYPEID )
22 #include <boost/current_function.hpp>
35 typeinfo( typeinfo const& );
36 typeinfo& operator=( typeinfo const& );
42 explicit typeinfo( char const * name ): name_( name )
46 bool operator==( typeinfo const& rhs ) const
51 bool operator!=( typeinfo const& rhs ) const
56 bool before( typeinfo const& rhs ) const
58 return std::less< typeinfo const* >()( this, &rhs );
61 char const* name() const
67 inline char const * demangled_name( core::typeinfo const & ti )
77 template<class T> struct core_typeid_
79 static boost::core::typeinfo ti_;
81 static char const * name()
83 return BOOST_CURRENT_FUNCTION;
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.
90 template<class T> boost::core::typeinfo core_typeid_< T >::ti_ = core_typeid_< T >::name();
92 template<class T> boost::core::typeinfo core_typeid_< T >::ti_(core_typeid_< T >::name());
95 template<class T> struct core_typeid_< T & >: core_typeid_< T >
99 template<class T> struct core_typeid_< T const >: core_typeid_< T >
103 template<class T> struct core_typeid_< T volatile >: core_typeid_< T >
107 template<class T> struct core_typeid_< T const volatile >: core_typeid_< T >
111 } // namespace detail
115 #define BOOST_CORE_TYPEID(T) (boost::detail::core_typeid_<T>::ti_)
119 #include <boost/core/demangle.hpp>
128 #if defined( BOOST_NO_STD_TYPEINFO )
130 typedef ::type_info typeinfo;
134 typedef std::type_info typeinfo;
138 inline std::string demangled_name( core::typeinfo const & ti )
140 return core::demangle( ti.name() );
147 #define BOOST_CORE_TYPEID(T) typeid(T)
151 #endif // #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED