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

Cast to a type.

Synopsis

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

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

Description

If U is the any itself (by any reference category), 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. Since the any argument is const, U cannot be a mutable reference.

Return Value

The value stored in arg, cast to U.

Template Parameters

Name

Description

U

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

Parameters

Name

Description

arg

A reference to a const std::any method argument.

Created with MrDocs