boost::openmethod::virtual_traits<std::any&, Registry>::cast

Cast to a type.

Synopsis

Declared in <boost/openmethod/interop/std_any.hpp>

template<typename U>
static
decltype(auto)
cast(std::any& arg);

Description

If U is the any itself, returns arg unchanged, which is how a catch‐all overrider is written. Otherwise, extracts the stored value using std::any_cast, and registers U, stripped of reference and cv‐qualifiers, in Registry as a class derived from std::any. Supports mutable references (e.g. Dog&) because the any argument is not const; modifications through the result are visible through the any.

Return Value

The value stored in arg, cast to U.

Template Parameters

Name

Description

U

The target type (e.g. Dog&, const Dog&, Dog).

Parameters

Name

Description

arg

A mutable reference to the std::any method argument.

Created with MrDocs