mirror of
https://github.com/boostorg/type_index.git
synced 2025-07-29 20:07:18 +02:00
Polished the docs and removed BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS and BOOST_TYPE_INDEX_REGISTER_STL_CLASS as was recommended during review. Moved helper headers to the detail folder.
This commit is contained in:
@ -269,9 +269,9 @@ Sometimes there may be a need to create your own type info system. This may be u
|
||||
|
||||
* `ctti_type_index` uses macro for getting full text representation of function name which could lead to code bloat,
|
||||
so prefer using `stl_type_index` type when possible.
|
||||
* `type_index` class hold a single pointer, so it is easy and fast to copy.
|
||||
* All the type_index classes hold a single pointer and are fast to copy.
|
||||
* Calls to `const char* raw_name()` do not require dynamic memory allocation and usually just return a pointer to an array of chars in a read-only section of the binary image.
|
||||
* Comparison operators are optimized as much as possible, and will at worst execute a single `std::strcmp`.
|
||||
* Comparison operators are optimized as much as possible and execute a single `std::strcmp` in worst case.
|
||||
* Calls to `std::string pretty_name()` usually require dynamic memory allocation and some computations, so they are not recommended for usage in performance critical sections.
|
||||
|
||||
[endsect]
|
||||
|
@ -16,20 +16,24 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_USER_TYPEINDEX)
|
||||
# include BOOST_TYPE_INDEX_USER_TYPEINDEX
|
||||
#elif (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
# include <boost/type_index/stl_type_index.hpp>
|
||||
# ifdef BOOST_NO_RTTI
|
||||
# include <boost/type_index/stl_register_class.hpp>
|
||||
# include <boost/type_index/detail/stl_register_class.hpp>
|
||||
# endif
|
||||
#else
|
||||
# include <boost/type_index/ctti_type_index.hpp>
|
||||
# include <boost/type_index/ctti_register_class.hpp>
|
||||
# include <boost/type_index/detail/ctti_register_class.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#ifndef BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
#define BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
#endif
|
||||
|
||||
namespace boost { namespace typeindex {
|
||||
@ -47,14 +51,8 @@ namespace boost { namespace typeindex {
|
||||
// Nothing to do
|
||||
#elif (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC)
|
||||
typedef boost::typeindex::stl_type_index type_index;
|
||||
# ifdef BOOST_NO_RTTI
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS BOOST_TYPE_INDEX_REGISTER_STL_CLASS
|
||||
# else
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
# endif
|
||||
#else
|
||||
typedef boost::typeindex::ctti_type_index type_index;
|
||||
# define BOOST_TYPE_INDEX_REGISTER_CLASS BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS
|
||||
#endif
|
||||
|
||||
/// Depending on a compiler flags, optimal implementation of type_info will be used
|
||||
@ -77,7 +75,7 @@ typedef type_index::type_info_t type_info;
|
||||
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_CLASS
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_CLASSis used to help to emulate RTTI.
|
||||
/// BOOST_TYPE_INDEX_REGISTER_CLASS is used to help to emulate RTTI.
|
||||
/// Put this macro into the public section of polymorphic class to allow runtime type detection.
|
||||
///
|
||||
/// Depending on the typeid() availability this macro will expand to nothing or to virtual helper function
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
/// \file compile_time_type_info.hpp
|
||||
/// \brief Contains helper macros and implementation details of boost::typeindex::ctti_type_index.
|
||||
/// Not intended for inclusion from user's code.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
@ -10,7 +10,8 @@
|
||||
#define BOOST_TYPE_INDEX_CTTI_REGISTER_CLASS_HPP
|
||||
|
||||
/// \file ctti_register_class.hpp
|
||||
/// \brief Contains BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS macro.
|
||||
/// \brief Contains BOOST_TYPE_INDEX_REGISTER_CLASS macro implementation that uses boost::typeindex::ctti_type_index.
|
||||
/// Not intended for inclusion from user's code.
|
||||
|
||||
#include <boost/type_index/ctti_type_index.hpp>
|
||||
|
||||
@ -27,17 +28,13 @@ inline const ctti_data& ctti_construct_typeid_ref(const T*) BOOST_NOEXCEPT {
|
||||
|
||||
}}} // namespace boost::typeindex::detail
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS
|
||||
/// BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS is used by BOOST_TYPE_INDEX_REGISTER_CLASS when RTTI is off
|
||||
/// and `typeid()` does not work.
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS macro expands to declaration and implementation of
|
||||
/// `virtual const type_info& boost_type_info_type_id_runtime_() const noexcept` method.
|
||||
#define BOOST_TYPE_INDEX_REGISTER_CTTI_CLASS \
|
||||
/// @cond
|
||||
#define BOOST_TYPE_INDEX_REGISTER_CLASS \
|
||||
virtual const boost::typeindex::detail::ctti_data& boost_type_index_type_id_runtime_() const BOOST_NOEXCEPT { \
|
||||
return boost::typeindex::detail::ctti_construct_typeid_ref(this); \
|
||||
} \
|
||||
/**/
|
||||
/// @endcond
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_CTTI_REGISTER_CLASS_HPP
|
||||
|
@ -10,7 +10,8 @@
|
||||
#define BOOST_TYPE_INDEX_STL_REGISTER_CLASS_HPP
|
||||
|
||||
/// \file stl_register_class.hpp
|
||||
/// \brief Contains BOOST_TYPE_INDEX_REGISTER_STL_CLASS macro.
|
||||
/// \brief Contains BOOST_TYPE_INDEX_REGISTER_CLASS macro implementation that uses boost::typeindex::stl_type_index.
|
||||
/// Not intended for inclusion from user's code.
|
||||
|
||||
#include <boost/type_index/stl_type_index.hpp>
|
||||
|
||||
@ -27,18 +28,13 @@ inline const stl_type_index::type_info_t& stl_construct_typeid_ref(const T*) BOO
|
||||
|
||||
}}} // namespace boost::typeindex::detail
|
||||
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_REGISTER_STL_CLASS
|
||||
/// BOOST_TYPE_INDEX_REGISTER_STL_CLASS is used by BOOST_TYPE_INDEX_REGISTER_CLASS when RTTI is off
|
||||
/// and `typeid()` does work.
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_REGISTER_STL_CLASS macro expands to declaration and implementation of
|
||||
/// `virtual const type_info& boost_type_info_type_id_runtime_() const noexcept` method.
|
||||
#define BOOST_TYPE_INDEX_REGISTER_STL_CLASS \
|
||||
/// @cond
|
||||
#define BOOST_TYPE_INDEX_REGISTER_CLASS \
|
||||
virtual const boost::typeindex::stl_type_index::type_info_t& boost_type_index_type_id_runtime_() const BOOST_NOEXCEPT { \
|
||||
return boost::typeindex::detail::stl_construct_typeid_ref(this); \
|
||||
} \
|
||||
/**/
|
||||
/// @endcond
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_STL_REGISTER_CLASS_HPP
|
||||
|
Reference in New Issue
Block a user