![]() |
Home | Libraries | People | FAQ | More |
type_index is just a typedef
for boost::typeindex::stl_type_index
or boost::typeindex::ctti_type_index.
Depending on the typeid()
availability TypeIndex library will choose an optimal class for type_index. In cases when at least basic
support for typeid()
is available stl_type_index
will be used.
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 virtual const type_info& boost_type_info_type_id_runtime_() const noexcept.Example: class A {
public:
BOOST_TYPE_INDEX_REGISTER_CLASS
virtual ~A(){}
};
struct B: public A {
BOOST_TYPE_INDEX_REGISTER_CLASS
};
struct C: public B {
BOOST_TYPE_INDEX_REGISTER_CLASS
};
...
C c1;
A* pc1 = &c1;
assert(boost::typeindex::type_id<C>() == boost::typeindex::type_id_runtime(*pc1));
macro is a helper macro that places some virtual helper functions or expands
to nothing.
BOOST_TYPE_INDEX_REGISTER_RUNTIME_CLASS
macro is a helper macro that places the same helpers as BOOST_TYPE_INDEX_REGISTER_CLASS
plus some additional helpers for boost::typeindex::runtime_cast to function.
Issues with cross module type comparison on a bugged compilers are bypassed by directly comparing strings with type (latest versions of those compilers resolved that issue using exactly the same approach).