boost::openmethod::virtual_traits<boost::type_erasure::any<C, T>&&, Registry>::cast

Cast to a type.

Synopsis

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

template<typename U>
requires (!std::is_rvalue_reference_v<U> || detail::te_owning<T>) &&
            (!detail::te_mutable_target<U> || detail::te_owning<T> ||
             detail::te_mutable_bound<T>)
static
decltype(auto)
cast(boost::type_erasure::any<C, T>&& arg);

Description

Extracts the bound value using boost::type_erasure::any_cast, and registers U, stripped of reference and cv‐qualifiers, in Registry as a class derived from the owning any. boost::type_erasure::any_cast has no rvalue overload, so, for an rvalue‐reference U, the result of a mutable‐reference cast is moved ‐ only for the owning any, since the rvalue‐ness of an any reference says nothing about the referent. Casting to a value also moves for the owning any, and copies otherwise. The disallowed overloads are removed from the overload set.

Return Value

The value bound to arg, cast to U.

Template Parameters

Name

Description

U

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

Parameters

Name

Description

arg

An rvalue reference to the any method argument.

Created with MrDocs