[3408] | 1 | #ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED |
---|
| 2 | #define BOOST_DETAIL_SP_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 | // detail/sp_typeinfo.hpp |
---|
| 11 | // |
---|
| 12 | // Copyright 2007 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 | |
---|
| 25 | namespace boost |
---|
| 26 | { |
---|
| 27 | |
---|
| 28 | namespace detail |
---|
| 29 | { |
---|
| 30 | |
---|
| 31 | class sp_typeinfo |
---|
| 32 | { |
---|
| 33 | private: |
---|
| 34 | |
---|
| 35 | sp_typeinfo( sp_typeinfo const& ); |
---|
| 36 | sp_typeinfo& operator=( sp_typeinfo const& ); |
---|
| 37 | |
---|
| 38 | char const * name_; |
---|
| 39 | |
---|
| 40 | public: |
---|
| 41 | |
---|
| 42 | explicit sp_typeinfo( char const * name ): name_( name ) |
---|
| 43 | { |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | bool operator==( sp_typeinfo const& rhs ) const |
---|
| 47 | { |
---|
| 48 | return this == &rhs; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | bool operator!=( sp_typeinfo const& rhs ) const |
---|
| 52 | { |
---|
| 53 | return this != &rhs; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | bool before( sp_typeinfo const& rhs ) const |
---|
| 57 | { |
---|
| 58 | return std::less< sp_typeinfo const* >()( this, &rhs ); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | char const* name() const |
---|
| 62 | { |
---|
| 63 | return name_; |
---|
| 64 | } |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | template<class T> struct sp_typeid_ |
---|
| 68 | { |
---|
| 69 | static sp_typeinfo ti_; |
---|
| 70 | |
---|
| 71 | static char const * name() |
---|
| 72 | { |
---|
| 73 | return BOOST_CURRENT_FUNCTION; |
---|
| 74 | } |
---|
| 75 | }; |
---|
| 76 | |
---|
| 77 | template<class T> sp_typeinfo sp_typeid_< T >::ti_ = sp_typeid_< T >::name(); |
---|
| 78 | |
---|
| 79 | template<class T> struct sp_typeid_< T & >: sp_typeid_< T > |
---|
| 80 | { |
---|
| 81 | }; |
---|
| 82 | |
---|
| 83 | template<class T> struct sp_typeid_< T const >: sp_typeid_< T > |
---|
| 84 | { |
---|
| 85 | }; |
---|
| 86 | |
---|
| 87 | template<class T> struct sp_typeid_< T volatile >: sp_typeid_< T > |
---|
| 88 | { |
---|
| 89 | }; |
---|
| 90 | |
---|
| 91 | template<class T> struct sp_typeid_< T const volatile >: sp_typeid_< T > |
---|
| 92 | { |
---|
| 93 | }; |
---|
| 94 | |
---|
| 95 | } // namespace detail |
---|
| 96 | |
---|
| 97 | } // namespace boost |
---|
| 98 | |
---|
| 99 | #define BOOST_SP_TYPEID(T) (boost::detail::sp_typeid_<T>::ti_) |
---|
| 100 | |
---|
| 101 | #else |
---|
| 102 | |
---|
| 103 | #include <typeinfo> |
---|
| 104 | |
---|
| 105 | namespace boost |
---|
| 106 | { |
---|
| 107 | |
---|
| 108 | namespace detail |
---|
| 109 | { |
---|
| 110 | |
---|
| 111 | #if defined( BOOST_NO_STD_TYPEINFO ) |
---|
| 112 | |
---|
| 113 | typedef ::type_info sp_typeinfo; |
---|
| 114 | |
---|
| 115 | #else |
---|
| 116 | |
---|
| 117 | typedef std::type_info sp_typeinfo; |
---|
| 118 | |
---|
| 119 | #endif |
---|
| 120 | |
---|
| 121 | } // namespace detail |
---|
| 122 | |
---|
| 123 | } // namespace boost |
---|
| 124 | |
---|
| 125 | #define BOOST_SP_TYPEID(T) typeid(T) |
---|
| 126 | |
---|
| 127 | #endif |
---|
| 128 | |
---|
| 129 | #endif // #ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED |
---|