diff --git a/doc/type_index.qbk b/doc/type_index.qbk index 9c45d5d..57af4d5 100644 --- a/doc/type_index.qbk +++ b/doc/type_index.qbk @@ -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] diff --git a/include/boost/type_index.hpp b/include/boost/type_index.hpp index 030e3b3..fe7fb81 100644 --- a/include/boost/type_index.hpp +++ b/include/boost/type_index.hpp @@ -16,20 +16,24 @@ #include +#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 # ifdef BOOST_NO_RTTI -# include +# include # endif #else # include -# include +# include #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 diff --git a/include/boost/type_index/detail/compile_time_type_info.hpp b/include/boost/type_index/detail/compile_time_type_info.hpp index 44c536c..173335c 100644 --- a/include/boost/type_index/detail/compile_time_type_info.hpp +++ b/include/boost/type_index/detail/compile_time_type_info.hpp @@ -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 #include diff --git a/include/boost/type_index/ctti_register_class.hpp b/include/boost/type_index/detail/ctti_register_class.hpp similarity index 69% rename from include/boost/type_index/ctti_register_class.hpp rename to include/boost/type_index/detail/ctti_register_class.hpp index cd9dc8e..a8cef2c 100644 --- a/include/boost/type_index/ctti_register_class.hpp +++ b/include/boost/type_index/detail/ctti_register_class.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 @@ -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 diff --git a/include/boost/type_index/stl_register_class.hpp b/include/boost/type_index/detail/stl_register_class.hpp similarity index 70% rename from include/boost/type_index/stl_register_class.hpp rename to include/boost/type_index/detail/stl_register_class.hpp index 8855775..95a26f7 100644 --- a/include/boost/type_index/stl_register_class.hpp +++ b/include/boost/type_index/detail/stl_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 @@ -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