BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS

Enable runtime checks in boost::openmethod::default_registry.

Synopsis

Declared in <boost/openmethod/default_registry.hpp>

#define BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS

Description

May be defined by a program before including <boost/openmethod/default_registry.hpp> to enable runtime checks. See boost::openmethod::default_registry for details.

Example

Define the symbol before including the library, or on the compiler command line:

#define BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS
#include <boost/openmethod.hpp>

The error goes to the registry's boost::openmethod::policies::error_handler policy, which writes the description shown in the comments; the program is then terminated. A handler may throw instead, to keep the program running.

The checks catch what boost::openmethod::initialize cannot. Below, Bulldog is never registered; nothing is amiss until a call passes one, and only then is boost::openmethod::missing_class reported:

// Bulldog is missing
BOOST_OPENMETHOD_CLASSES(Animal, Dog);

BOOST_OPENMETHOD(poke, (virtual_ptr<Animal>), void);

BOOST_OPENMETHOD_OVERRIDE(poke, (virtual_ptr<Dog>), void) {
    // ...
}

Bulldog hector;

// aborts with error message: unknown class Bulldog
poke(hector);

Without the checks the same call proceeds on a v‐table pointer that was never set up, and the behavior is undefined.

See Also