diff --git a/boost/type_index.hpp b/boost/type_index.hpp index b9208c3..ee6e7c4 100644 --- a/boost/type_index.hpp +++ b/boost/type_index.hpp @@ -44,7 +44,10 @@ namespace boost { namespace detail { -#ifdef _MSC_VER +#if defined(BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP) && defined(BOOST_TYPE_INDEX_CTTI_END_SKIP) + BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP); // skip user specified bytes count + BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_end = BOOST_TYPE_INDEX_CTTI_END_SKIP); // skip user specified bytes count +#elif defined _MSC_VER // sizeof("const char *__cdecl boost::detail::ctti<") - 1 BOOST_STATIC_CONSTANT(std::size_t, ctti_skip_size_at_begin = 40); diff --git a/libs/type_index/doc/type_index.qbk b/libs/type_index/doc/type_index.qbk index 1f60f01..42cedfa 100644 --- a/libs/type_index/doc/type_index.qbk +++ b/libs/type_index/doc/type_index.qbk @@ -14,7 +14,7 @@ Sometimes getting and storing information about a template type at runtime is required. For such cases a construction like `&typeid(T)` or C++11 class `std::type_index` is usually used. And that is the point, where problems strat: * `typeid(T)` and `std::type_index` require Run Time Type Info (RTTI) -* some implementations of `typeid(T)` strips const, volatile and references from type, while others don't +* some implementations of `typeid(T)` strip const, volatile and references from type, while others don't * some compilers have bugs and do not correctly compare `std::type_info` objects across shared libraries * only a few implementations already provide `std::type_index` * no easy way to store type info without stripping const, volatile and references @@ -22,7 +22,7 @@ Sometimes getting and storing information about a template type at runtime is re Boost.TypeIndex was designed to work around those issues. -[note `T` means type here. Think of it as `T` in `template ` ] +[note `T` means type here. Think of it as of `T` in `template ` ] [warning This library is not accepted to Boost, it is currrently waiting for review. ] @@ -79,6 +79,13 @@ int main () { std::cout << "Has type int: " << tr.has_type() << "\nHas type std::string: " << tr.has_type() << '\n'; + + try { + tr.add_type(); // Will throw + } catch (const std::logic_error& e) { + // Will print "Type int already registered" + std::cout << e.what() << std::endl; + } } ``