BOOST_OPENMETHOD_OVERRIDE
Synopsis
Defined in <boost/openmethod/macros.hpp>.
BOOST_OPENMETHOD_OVERRIDE(NAME, (PARAMETERS...), RETURN_TYPE) {
// body
}
Description
BOOST_OPENMETHOD_OVERRIDE
adds an overrider to a method.
The method is deduced from a call to a method guide function with the overrider’s arguments.
The macro creates several entities in the current scope.
-
A class template that acts as a container for the overriders of the methods called
NAME
:
template<typename...> BOOST_OPENMETHOD_OVERRIDERS(NAME);
-
A specialization of the container template for the overrider:
struct BOOST_OPENMETHOD_OVERRIDERS(NAME)<RETURN_TYPE(PARAMETERS...)> {
static auto fn(PARAMETERS...) -> RETURN_TYPE;
static auto has_next() -> bool;
template<typename... Args>
static auto next(typename... Args) -> RETURN_TYPE;
};
where:
-
fn
is the overrider function. -
has_next()
returnstrue
if a less specialized overrider exists. -
next(Args… args)
calls the next most specialized overrider via the pointer stored in the method’snext<fn>
member variable.
Finally, the macro starts the definition of the overrider function:
auto BOOST_OPENMETHOD_OVERRIDERS(NAME)<RETURN_TYPE(PARAMETERS...)>::fn(
PARAMETERS...) -> RETURN_TYPE
The block following the call to the macro is the body of the function.
NAME must be an identifier. Qualified names are not allowed.
|