Namespaces
Variants
Views
Actions

std::experimental::any_cast

From cppreference.com
< cpp‎ | experimental‎ | any
template<class ValueType>
    ValueType any_cast(const any& operand);
(1) (library fundamentals TS)
template<class ValueType>
    ValueType any_cast(any& operand);
(2) (library fundamentals TS)
template<class ValueType>
    ValueType any_cast(any&& operand);
(3) (library fundamentals TS)
template<class ValueType>
    const ValueType* any_cast(const any* operand);
(4) (library fundamentals TS)
template<class ValueType>
    ValueType* any_cast(any* operand);
(5) (library fundamentals TS)

Performs type-safe access to the contained object.

[edit] Parameters

operand - target any object

[edit] Return value

1-3) The value, or a reference to the value contained by operand. If the requested ValueType is a reference, it is const-qualified for (1).
4-5) If operand is not a null pointer, and the typeid of the requested ValueType matches that of the contents of operand, a pointer to the value contained by operand, otherwise a null pointer. The returned pointer is const qualified for (4).

[edit] Exceptions

1-3) Throws bad_any_cast if the typeid of the requested ValueType does not match that of the contents of operand.
4-5)
noexcept specification:  
noexcept