Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This is an older version of Boost and was released in 2018. The current version is 1.89.0.
BOOST_TYPE_INDEX_REGISTER_CLASS
// In header: <boost/type_index.hpp>
BOOST_TYPE_INDEX_REGISTER_CLASSBOOST_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));