forked from boostorg/type_index
Attempt to optimize MSVC calls to typeid with RTTI off
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_index/type_info.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
// MSVC is capable of calling typeid(T) even when RTTI is off
|
||||
#if (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
#if !defined(BOOST_NO_IOSFWD)
|
||||
@@ -205,7 +206,7 @@ inline std::size_t hash_value(type_index const& v) BOOST_NOEXCEPT {
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#else // !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
#else // (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#include <boost/type_index/template_index.hpp>
|
||||
namespace boost {
|
||||
@@ -214,7 +215,7 @@ typedef template_index type_index;
|
||||
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
#endif // (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TYPE_INDEX_HPP
|
||||
|
||||
|
@@ -22,11 +22,13 @@
|
||||
///
|
||||
/// boost::type_info class is used in situations when RTTI is enabled.
|
||||
/// When RTTI is disabled or BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY macro is defined boost::template_info
|
||||
/// is used instead of it.
|
||||
/// is usually used instead of it.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
|
||||
// MSVC is capable of calling typeid(T) even when RTTI is off
|
||||
#if (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
@@ -136,6 +138,10 @@ public:
|
||||
/// This method available only with RTTI enabled.
|
||||
template <class T>
|
||||
static const type_info& construct_rtti_only(T& rtti_val) BOOST_NOEXCEPT {
|
||||
#ifdef BOOST_NO_RTTI
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(T) && false,
|
||||
"boost::type_id_rtti_only(T&) and boost::type_info::construct_rtti_only(T&) require RTTI");
|
||||
#endif
|
||||
return static_cast<const boost::type_info&>(typeid(rtti_val));
|
||||
}
|
||||
|
||||
@@ -143,6 +149,10 @@ public:
|
||||
/// This method available only with RTTI enabled.
|
||||
template <class T>
|
||||
static const type_info& construct_rtti_only(T* rtti_val) {
|
||||
#ifdef BOOST_NO_RTTI
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(T) && false,
|
||||
"boost::type_id_rtti_only(T*) and boost::type_info::construct_rtti_only(T*) require RTTI");
|
||||
#endif
|
||||
return static_cast<const boost::type_info&>(typeid(rtti_val));
|
||||
}
|
||||
|
||||
@@ -334,7 +344,7 @@ inline const type_info& type_id_rtti_only(T* rtti_val) {
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)
|
||||
#endif // (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY)) || defined (BOOST_MSVC)
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
/// \def BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[library Boost.TypeIndex
|
||||
[quickbook 1.6]
|
||||
[version 2.0]
|
||||
[version 2.1]
|
||||
[copyright 2012-2013 Antony Polukhin]
|
||||
[category Language Features Emulation]
|
||||
[license
|
||||
|
Reference in New Issue
Block a user