diff --git a/README.md b/README.md index fc5e779..abed6bf 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ type_index ========== -Runtime/Compile time copyable type info. Library is waiting for boost reiew. -Documantation available at: http://apolukhin.github.com/type_index/index.html +Runtime/Compile time copyable type info. +Documantation available at: http://www.boost.org/ +Latest developer documentation is available at: http://boostorg.github.com/type_index/index.html Distributed under the Boost Software License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt). -While ticket #9228 is not solved, use boost_test_no_rtti.patch to make the tests compile. diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 3d9c175..073258a 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -11,6 +11,7 @@ doxygen autodoc : [ glob ../../../boost/type_index.hpp ] [ glob ../../../boost/type_index/*.hpp ] + [ glob ../../../boost/type_index/detail/*.hpp ] : EXTRACT_ALL=NO HIDE_UNDOC_MEMBERS=YES diff --git a/doc/type_index.qbk b/doc/type_index.qbk index 6a5b90c..9c45d5d 100644 --- a/doc/type_index.qbk +++ b/doc/type_index.qbk @@ -301,33 +301,6 @@ i TypeIndex has been tested and successfully work on many compilers. -[\ -DB_TYPE_INDEX_CTTI_USER_DEFINED_PARSING='BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(1, 1, false, "")' ] -If `BOOST_TYPE_INDEX_FUNCTION_SIGNATURE` macro is not defined or -`BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` -are defined to zero then you are using a compiler that was not tested with this library. -In that case if you wish to use this library with RTTI off, you must correctly define -`BOOST_TYPE_INDEX_FUNCTION_SIGNATURE`, `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and -`BOOST_TYPE_INDEX_CTTI_END_SKIP` macros: - -# define `BOOST_TYPE_INDEX_FUNCTION_SIGNATURE` to a compiler specific macro, that outputs the *whole* -function signature, including template parameters -# get the output of `boost::typeindex::ctti_type_index::type_id().name()` -# set `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` equal to characters count before last occurrence of `int` in output -# set `BOOST_TYPE_INDEX_CTTI_END_SKIP` equal to characters count after last occurrence of `int` in output -# check that `boost::typeindex::ctti_type_index::type_id().name_demangled()` returns "int" -# (optional, but highly recomended) [@http://www.boost.org/support/bugs.html create ticket] with -feature request to add your compiler to supported compilers list. Include -`BOOST_TYPE_INDEX_FUNCTION_SIGNATURE`, `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and -`BOOST_TYPE_INDEX_CTTI_END_SKIP` values. - -Consider the following example: - -With `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` set to `0`, -`boost::typeindex::ctti_type_index::type_id().raw_name()` returns -"const char *__cdecl boost::detail::ctti::n(void)". Then you shall set -`BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` to `sizeof("const char *__cdecl boost::detail::ctti<") - 1` -and `BOOST_TYPE_INDEX_CTTI_END_SKIP` to `sizeof(">::n(void)") - 1`. - [warning With RTTI off classes with exactly the same names defined in different modules in anonymous namespaces may collapse: ``` @@ -346,6 +319,72 @@ and `BOOST_TYPE_INDEX_CTTI_END_SKIP` to `sizeof(">::n(void)") - 1`. *Compilers that have that limitation:* GCC, CLANG. ] +[section Define the BOOST_TYPE_INDEX_FUNCTION_SIGNATURE macro] + +If you get the following error during compilation +`` + 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. + Define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING to correct value after that. +`` +then you are using a compiler that was not tested with this library. + +[macroref BOOST_TYPE_INDEX_FUNCTION_SIGNATURE] must be defined to a compiler specific macro, that outputs the *whole* +function signature including template parameters. + + +[endsect] + +[section Fixing pretty_name() output] + +If the output of `boost::typeindex::ctti_type_index::type_id().name()` +* returns not just `int` but also a lot of text around the `int` +* or does not return type at all +then you are usng a compiler that was not tested with this library and you need to setup the +[macroref BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING] macro using [macroref BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS]. + +Here is a short instruction: + +# get the output of `boost::typeindex::ctti_type_index::type_id().name()` +# define [macroref BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING] to +`BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(skip_at_begin, skip_at_end, false, "")`, where + * `skip_at_begin` is equal to characters count before the first occurrence of `int` in output + * `skip_at_end` is equal to characters count after last occurrence of `int` in output +# check that `boost::typeindex::ctti_type_index::type_id().name_demangled()` returns "int" +# if it does not return `int`, then define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING to +`BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(skip_at_begin, skip_at_end, true, "T = ")`, where + * `skip_at_begin` is equal to `skip_at_begin` at step 2 + * `skip_at_end` is equal to `skip_at_end` at step 2 + * `"T = "` is equal to characters that are right before the `int` in output +# (optional, but highly recomended) [@http://www.boost.org/support/bugs.html create ticket] with +feature request to add your compiler to supported compilers list. Include +parameters provided to `BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS` macro. + + +Consider the following example: + +`boost::typeindex::ctti_type_index::type_id().raw_name()` returns +"const char *__cdecl boost::detail::ctti::n(void)". Then you shall set +`skip_at_begin` to `sizeof("const char *__cdecl boost::detail::ctti<") - 1` +and `skip_at_end` to `sizeof(">::n(void)") - 1`. + +`` +#define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(39, 6, false, "") +`` + +Another example: + +`boost::typeindex::ctti_type_index::type_id().raw_name()` returns +"static const char *boost::detail::ctti::n() [T = int]"". Then you shall set +`skip_at_begin` to `sizeof("static const char *boost::detail::ctti<") - 1` +and `skip_at_end` to `sizeof("]") - 1` and last parameter of macto to "T = ". + +`` +#define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(39, 1, true, "T = ") +`` + +[endsect] [endsect] 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 3ce4cf1..8fb40af 100644 --- a/include/boost/type_index/detail/compile_time_type_info.hpp +++ b/include/boost/type_index/detail/compile_time_type_info.hpp @@ -9,20 +9,58 @@ #ifndef BOOST_TYPE_INDEX_DETAIL_COMPILE_TIME_TYPE_INFO_HPP #define BOOST_TYPE_INDEX_DETAIL_COMPILE_TIME_TYPE_INFO_HPP -// MS compatible compilers support #pragma once -#if defined(_MSC_VER) -# pragma once -#endif - - /// \file compile_time_type_info.hpp -/// \brief Contains implementation of boost::ctti class. +/// \brief Contains helper macros and implementation details of boost::typeindex::ctti_type_index. #include #include #include #include +#ifdef BOOST_HAS_PRAGMA_ONCE +# pragma once +#endif + +/// \def BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(begin_skip, end_skip, runtime_skip, runtime_skip_until) +/// This is a helper macro for making correct pretty_names() with RTTI off. +/// +/// \b Example: +/// +/// Imagine the situation when +/// \code boost::typeindex::ctti_type_index::type_id().pretty_name() \endcode +/// returns the following string: +/// \code "static const char *boost::detail::ctti::n() [T = int]" \endcode +/// and \code boost::typeindex::ctti_type_index::type_id().pretty_name() \endcode returns the following: +/// \code "static const char *boost::detail::ctti::n() [T = short]" \endcode +/// +/// As we may see first 39 characters are "static const char *boost::detail::ctti<" and they do not depend on +/// the type T. After first 39 characters we have a human readable type name which is duplicated at the end +/// of a string. String always ends on ']', which consumes 1 character. +/// +/// Now if we define `BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING` to +/// `BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING(39, 1, false, "")` we'll be getting \code "int>::n() [T = int" \endcode +/// for `boost::typeindex::ctti_type_index::type_id().pretty_name()` and \code "short>::n() [T = short" \endcode +/// for `boost::typeindex::ctti_type_index::type_id().pretty_name()`. +/// +/// Now we need to take additional care of the characters that go before the last mention of our type. We'll +/// do that by telling the macro that we need to cut off everything that goes before the "T = " including the "T = " +/// itself: +/// +/// \code BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING(39, 1, true, "T = ") \endcode +/// +/// In case of GCC or Clang command line we need to add the following line while compiling al lthe sources: +/// +/// \code +/// -DBOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING='BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING(39, 1, true, "T = ")' +/// \endcode +/// \param begin_skip How many characters must be skipped at the beginning of the type holding string. +/// Must be a compile time constant. +/// \param end_skip How many characters must be skipped at the end of the type holding string. +/// Must be a compile time constant. +/// \param runtime_skip Do we need additional checks at runtime to cut off the more characters. +/// Must be `true` or `false`.l +/// \param runtime_skip_until Skip all the characters before the following string (including the string itself). +/// Must be a compile time array of characters. #define BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(begin_skip, end_skip, runtime_skip, runtime_skip_until) \ namespace boost { namespace typeindex { namespace detail { \ BOOST_STATIC_CONSTEXPR std::size_t ctti_skip_size_at_begin = begin_skip; \ @@ -36,25 +74,28 @@ #if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED) /// \def BOOST_TYPE_INDEX_FUNCTION_SIGNATURE -/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE is used by boost::template_info 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_info, you may +/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE is used by boost::typeindex::ctti_type_index class to +/// deduce the name of a type. If your compiler is not recognized +/// by the TypeIndex library and you wish to work with boost::typeindex::ctti_type_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. +/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE must be defined to a compiler specific macro +/// that outputs the \b whole function signature \b including \b template \b 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::typeindex::ctti_type_index classes. +/// +/// See BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS and BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING +/// for an information of how to tune the implementation to make a nice retty_name() output. #define BOOST_TYPE_INDEX_FUNCTION_SIGNATURE BOOST_CURRENT_FUNCTION /// \def BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING /// -/// BOOST_TYPE_INDEX_FUNCTION_SIGNATURE, BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP -/// and BOOST_TYPE_INDEX_CTTI_END_SKIP macroses are used for adding a +/// BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING macro may be defined to +/// BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(begin_skip, end_skip, runtime_skip, runtime_skip_until) with parameters for adding a /// support for compilers, that by default are not recognized by TypeIndex library. /// -/// See Compiler support for more info +/// See 'RTTI emulation limitations' for more info #define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING BOOST_TYPE_INDEX_REGISTER_CTTI_PARSING_PARAMS(0, 0, false, ""); #elif defined(BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING) @@ -142,8 +183,7 @@ struct ctti { "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." + "Define BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING to correct value after that." ); #endif } diff --git a/patched/boost_test.patch b/patched/boost_test.patch deleted file mode 100644 index e5348f1..0000000 --- a/patched/boost_test.patch +++ /dev/null @@ -1,58 +0,0 @@ -From fcd4da81d14847272fa888f4e9a54930b48ee95b Mon Sep 17 00:00:00 2001 -From: Antony Polukhin -Date: Sat, 11 Jan 2014 19:19:20 +0400 -Subject: [PATCH] Make Boost.Test work with RTTI disabled (fixes #9228) - ---- - include/boost/test/execution_monitor.hpp | 2 +- - include/boost/test/tree/test_case_template.hpp | 13 +++++++++++-- - 2 files changed, 12 insertions(+), 3 deletions(-) - -diff --git a/include/boost/test/execution_monitor.hpp b/include/boost/test/execution_monitor.hpp -index f6b7681..259f97c 100644 ---- a/include/boost/test/execution_monitor.hpp -+++ b/include/boost/test/execution_monitor.hpp -@@ -261,7 +261,7 @@ public: - template - void erase_exception_translator( boost::type* = 0 ) - { -- m_custom_translators = m_custom_translators->erase( m_custom_translators ); -+ m_custom_translators = m_custom_translators->template erase( m_custom_translators ); - } - - private: -diff --git a/include/boost/test/tree/test_case_template.hpp b/include/boost/test/tree/test_case_template.hpp -index 9f7466a..b0fa634 100644 ---- a/include/boost/test/tree/test_case_template.hpp -+++ b/include/boost/test/tree/test_case_template.hpp -@@ -34,8 +34,13 @@ - #include - #include - --// STL -+#ifndef BOOST_NO_RTTI - #include // for typeid -+#else -+#include -+#endif -+ -+// STL - #include // for std::string - #include // for std::list - -@@ -77,7 +82,11 @@ struct generate_test_case_4_type { - std::string full_name; - assign_op( full_name, m_test_case_name, 0 ); - full_name += '<'; -- full_name += typeid(TestType).name(); -+#ifndef BOOST_NO_RTTI -+ full_name += typeid(TestType).name(); -+#else -+ full_name += BOOST_CURRENT_FUNCTION; -+#endif - if( boost::is_const::value ) - full_name += " const"; - full_name += '>'; --- -1.8.5.3 -