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>
36 typeinfo( typeinfo const& );
37 typeinfo& operator=( typeinfo const& );
44 typeinfo( char const * name, void (*lib_id)() ): name_( name ), lib_id_( lib_id )
48 bool operator==( typeinfo const& rhs ) const
50 #if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
52 return lib_id_ == rhs.lib_id_? this == &rhs: std::strcmp( name_, rhs.name_ ) == 0;
61 bool operator!=( typeinfo const& rhs ) const
63 return !( *this == rhs );
66 bool before( typeinfo const& rhs ) const
68 #if ( defined(_WIN32) || defined(__CYGWIN__) ) && ( defined(__GNUC__) || defined(__clang__) ) && !defined(BOOST_DISABLE_CURRENT_FUNCTION)
70 return lib_id_ == rhs.lib_id_? std::less< typeinfo const* >()( this, &rhs ): std::strcmp( name_, rhs.name_ ) < 0;
74 return std::less< typeinfo const* >()( this, &rhs );
79 char const* name() const
85 inline char const * demangled_name( core::typeinfo const & ti )
95 template<class T> struct BOOST_SYMBOL_VISIBLE core_typeid_
97 static boost::core::typeinfo ti_;
99 static char const * name()
101 return BOOST_CURRENT_FUNCTION;
105 BOOST_SYMBOL_VISIBLE inline void core_typeid_lib_id()
109 template<class T> boost::core::typeinfo core_typeid_< T >::ti_( core_typeid_< T >::name(), &core_typeid_lib_id );
111 template<class T> struct core_typeid_< T & >: core_typeid_< T >
115 template<class T> struct core_typeid_< T const >: core_typeid_< T >
119 template<class T> struct core_typeid_< T volatile >: core_typeid_< T >
123 template<class T> struct core_typeid_< T const volatile >: core_typeid_< T >
127 } // namespace detail
131 #define BOOST_CORE_TYPEID(T) (boost::detail::core_typeid_<T>::ti_)
135 #include <boost/core/demangle.hpp>
144 #if defined( BOOST_NO_STD_TYPEINFO )
146 typedef ::type_info typeinfo;
150 typedef std::type_info typeinfo;
154 inline std::string demangled_name( core::typeinfo const & ti )
156 return core::demangle( ti.name() );
163 #define BOOST_CORE_TYPEID(T) typeid(T)
167 #endif // #ifndef BOOST_CORE_TYPEINFO_HPP_INCLUDED