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

Cast to a type.

Synopsis

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

template<typename U>
requires !std::is_reference_v<U> ||
            std::is_const_v<std::remove_reference_t<U>>
static
decltype(auto)
cast(boost::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 boost::any_cast, and registers U, stripped of reference and cv‐qualifiers, in Registry as a class derived from boost::any.

Since the any argument is const, U cannot be a mutable reference. boost::any_cast rewrites U to a const reference for a const any, and would fail inside Boost.Any; this overload is removed from the overload set instead.

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 boost::any method argument.

Created with MrDocs