| Home | Libraries | People | FAQ | More

## Macro BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING

BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING

## Synopsis

    // In header: <boost/type_index.hpp>

    BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING

## Description

This is a helper macro for making correct pretty_names() with RTTI off.

BOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING macro may be defined to '(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.

Example:

Imagine the situation when

    boost::typeindex::ctti_type_index::type_id<int>().pretty_name()

returns the following string:

    "static const char *boost::detail::ctti<int>::n() [T = int]"

and

    boost::typeindex::ctti_type_index::type_id<short>().pretty_name()

returns the following:

    "static const char *boost::detail::ctti<short>::n() [T = short]"

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 `(39, 1, false, "")` we'll be getting

    "int>::n() [T = int"

for `boost::typeindex::ctti_type_index::type_id<int>().pretty_name()` and

    "short>::n() [T = short"

for `boost::typeindex::ctti_type_index::type_id<short>().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:

    (39, 1, true, "T = ")

In case of GCC or Clang command line we need to add the following line while compiling all the sources:

    -DBOOST_TYPE_INDEX_CTTI_USER_DEFINED_PARSING='(39, 1, true, "T = ")'

See RTTI emulation limitations for more info.