libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ any_cast() [1/5]

template<typename _ValueType, typename enable_if<!is_move_constructible< _ValueType >::value||is_lvalue_reference< _ValueType >::value, bool >::type = true>
_ValueType std::experimental::fundamentals_v1::any_cast ( any && __any)
inline

Access the contained object.

Template Parameters
_ValueTypeA reference or CopyConstructible type.
Parameters
__anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf __any.type() != typeid(remove_reference_t<_ValueType>)

Definition at line 396 of file experimental/any.

397 {
398 static_assert(any::__is_valid_cast<_ValueType>(),
399 "Template argument must be a reference or CopyConstructible type");
400 auto __p = any_cast<remove_reference_t<_ValueType>>(&__any);
401 if (__p)
402 return *__p;
403 __throw_bad_any_cast();
404 }
_ValueType any_cast(const any &__any)
Access the contained object.