forked from boostorg/type_index
Improved the documentation and static assertion added for situations when compiler is not detected and boost::template_index is used.
This commit is contained in:
@@ -11,9 +11,10 @@
|
||||
/// \file type_index.hpp
|
||||
/// \brief Includes all the headers of the Boost.TypeIndex library.
|
||||
///
|
||||
/// By inclusion of this file both classes (`type_index` (if RTTI is on) and `template_index`) will be available.
|
||||
/// Consider including `<boost/type_index/type_index_minimal.hpp>` if you do not whant to include `template_index` class
|
||||
/// while RTTI is available (this is recommended).
|
||||
/// By inclusion of this file both classes (boost::type_index if RTTI is on and boost::template_index) will be available.
|
||||
///
|
||||
/// Consider including <boost/type_index/type_index_minimal.hpp> if you do not whant to include
|
||||
/// boost::template_index class while RTTI is available (this is recommended).
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
|
@@ -20,12 +20,11 @@
|
||||
#endif
|
||||
|
||||
/// \file template_index_impl.hpp
|
||||
/// \brief Contains implementation of template_index class.
|
||||
/// \brief Contains implementation of boost::template_index class.
|
||||
///
|
||||
/// Here is defined the `boost::template_index` class, that is used instead of `boost::type_index`
|
||||
/// class in situations when RTTI is disabled.
|
||||
/// boost::template_index class is used instead of boost::type_index class in situations when RTTI is disabled.
|
||||
///
|
||||
/// Consider including `<boost/type_index/type_index_minimal.hpp>` or `<boost/type_index.hpp>` instead of this file.
|
||||
/// Consider including <boost/type_index/type_index_minimal.hpp> or <boost/type_index.hpp> instead of this file.
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
@@ -48,21 +47,57 @@
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
|
||||
/// \def BOOST_TYPE_INDEX_FUNCTION_SIGNATURE
|
||||
/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE is used by boost::template_index class to
|
||||
/// deduce the name of a template parameter. If your compiler is not recognized
|
||||
/// by the TypeIndex library and you wish to work with boost::template_index, you may
|
||||
/// define this macro by yourself.
|
||||
///
|
||||
/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE must be defined to a compiler specific macro,
|
||||
/// that outputs the WHOLE function signature, including template parameters.
|
||||
///
|
||||
/// If your compiler is not recognised and BOOST_TYPE_INDEX_FUNCTION_SIGNATURE is not defined,
|
||||
/// then a compile-time error will arise at any attempt to use boost::template_index class.
|
||||
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE BOOST_CURRENT_FUNCTION
|
||||
|
||||
#elif defined(BOOST_TYPE_INDEX_FUNCTION_SIGNATURE)
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert(){}
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_FUNCTION_SIGNATURE)
|
||||
// Do nothing
|
||||
#elif defined(__FUNCSIG__)
|
||||
# define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __FUNCSIG__
|
||||
#elif defined(__GNUC__) \
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert(){}
|
||||
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __FUNCSIG__
|
||||
|
||||
#elif defined(__PRETTY_FUNCTION__) \
|
||||
|| defined(__GNUC__) \
|
||||
|| (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) \
|
||||
|| (defined(__ICC) && (__ICC >= 600)) \
|
||||
|| defined(__ghs__) \
|
||||
|| defined(__DMC__)
|
||||
# define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __PRETTY_FUNCTION__
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert(){}
|
||||
#define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE __PRETTY_FUNCTION__
|
||||
|
||||
#else
|
||||
# error TypeIndex library could not detect your compiler.
|
||||
# error Please make the BOOST_TYPE_INDEX_FUNCTION_SIGNATURE macro use
|
||||
# error correct compiler macro for getting the whole function name.
|
||||
|
||||
template <class T>
|
||||
inline void lazy_function_signature_assert() {
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
sizeof(T) && false,
|
||||
"TypeIndex library could not detect your compiler. "
|
||||
"Please make the BOOST_TYPE_INDEX_FUNCTION_SIGNATURE macro use "
|
||||
"correct compiler macro for getting the whole function name. "
|
||||
"Do not forget to also define BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP and "
|
||||
"BOOST_TYPE_INDEX_CTTI_END_SKIP."
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP) && defined(BOOST_TYPE_INDEX_CTTI_END_SKIP)
|
||||
@@ -106,6 +141,7 @@ namespace detail {
|
||||
|
||||
/// Returns raw name. Must be as short, as possible, to avoid code bloat
|
||||
static const char* n() BOOST_NOEXCEPT {
|
||||
lazy_function_signature_assert<T>();
|
||||
return BOOST_TYPE_INDEX_FUNCTION_SIGNATURE + detail::ctti_skip_size_at_begin;
|
||||
}
|
||||
|
||||
|
@@ -19,10 +19,13 @@
|
||||
#endif
|
||||
|
||||
/// \file type_index_impl.hpp
|
||||
/// \brief Contains implementation of type_index class.
|
||||
/// \brief Contains implementation of boost::type_index class.
|
||||
///
|
||||
/// Here is defined the type_index class, that is used in situations when RTTI is enabled.
|
||||
/// Consider including `<boost/type_index/type_index_minimal.hpp>` or `<boost/type_index.hpp>` instead of this file.
|
||||
/// boost::type_index 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_index
|
||||
/// is used instead.
|
||||
///
|
||||
/// Consider including <boost/type_index/type_index_minimal.hpp> or <boost/type_index.hpp> instead of this file.
|
||||
|
||||
|
||||
#include <cstring>
|
||||
|
@@ -15,13 +15,10 @@
|
||||
#endif
|
||||
|
||||
/// \file type_index_minimal.hpp
|
||||
/// \brief This is the header that required for ussage of type_index with/without RTTI.
|
||||
/// \brief This is the header that required for ussage of boost::type_index with/without RTTI.
|
||||
///
|
||||
/// It includes only the minamally required headers and does the `typedef template_index type_index;`
|
||||
/// It includes only the minamally required headers and does the 'typedef template_index type_index;'
|
||||
/// when RTTI is disabled.
|
||||
///
|
||||
/// Define the BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY macro if you are mixing objects
|
||||
/// compiled with different RTTI flags.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
@@ -61,6 +58,13 @@ inline type_index type_id_rtti_only(T* rtti_val) {
|
||||
|
||||
#endif // BOOST_NO_RTTI
|
||||
|
||||
#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
|
||||
/// \def BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY
|
||||
/// Define the BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY macro if you are mixing objects
|
||||
/// compiled with different RTTI flags. This will force the usage of boost::template_index
|
||||
/// class instead of boost::type_index.
|
||||
#define BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY
|
||||
#endif // BOOST_TYPE_INDEX_DOXYGEN_INVOKED
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TYPE_INDEX_MINIMAL_HPP
|
||||
|
||||
|
@@ -106,8 +106,9 @@ i
|
||||
|
||||
[section Compiler support]
|
||||
|
||||
TypeIndex has been tested and sucessfully work on MSVC2010, GCC-4.5, Clang-2.9. If your compiler is not in a list of tested compilers, you shall correctly define `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` macroses:
|
||||
TypeIndex has been tested and sucessfully work on MSVC2010, GCC-4.5, Clang-2.9. If your compiler is not in a list of tested compilers, you shall correctly define `BOOST_TYPE_INDEX_FUNCTION_SIGNATURE`,`BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` macroses:
|
||||
|
||||
# define `BOOST_TYPE_INDEX_FUNCTION_SIGNATURE` to a a compiler specific macro, that outputs the *whole* function signature, including template parameters
|
||||
# define `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` to `0`
|
||||
# get the output of `boost::detail::ctti<int>::n()`
|
||||
# set `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` equal to characters count before last occurrence of `int` in output
|
||||
|
Reference in New Issue
Block a user