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 the documentation for a snapshot of the master branch, built from commit 064f557086.
PrevUpHomeNext

Macro BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST

BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST — Macro used to make a class compatible with boost::typeindex::runtime_cast without including support for boost::typeindex::type_id_runtime.

Synopsis

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

BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(...)

Description

BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST is provided as an alternative to BOOST_TYPE_INDEX_REGISTER_RUNTIME_CLASS in the event that support for boost::typeindex::type_id_runtime is undesirable.

Example:

struct base1 {
    BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST()
    virtual ~base1();
};

struct base2 {
    BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST()
    virtual ~base2();
};

struct derived1 : base1 {
    BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(base1)
};

struct derived2 : base1, base2 {
    BOOST_TYPE_INDEX_IMPLEMENT_RUNTIME_CAST(base1, base2)
};

...

base1* pb1 = get_object();
if(derived2* pb2 = boost::typeindex::runtime_cast<derived2*>(pb1))
{ /* can't call boost::typeindex::type_id_runtime(*pb1) here */ }


PrevUpHomeNext