std::experimental:: any_cast
From cppreference.net
<
cpp
|
experimental
|
any
|
template
<
class
ValueType
>
ValueType any_cast ( const any & operand ) ; |
(1) | (Bibliothek Fundamentals TS) |
|
template
<
class
ValueType
>
ValueType any_cast ( any & operand ) ; |
(2) | (Bibliothek Fundamentals TS) |
|
template
<
class
ValueType
>
ValueType any_cast ( any && operand ) ; |
(3) | (Bibliothek Fundamentals TS) |
|
template
<
class
ValueType
>
const ValueType * any_cast ( const any * operand ) noexcept ; |
(4) | (Bibliothek Fundamentals TS) |
|
template
<
class
ValueType
>
ValueType * any_cast ( any * operand ) noexcept ; |
(5) | (Bibliothek Fundamentals TS) |
Führt typsicheren Zugriff auf das enthaltene Objekt aus.
Für
(1-3)
ist das Programm fehlerhaft, wenn
ValueType
kein Referenztyp ist und
std::
is_copy_constructible
<
ValueType
>
::
value
den Wert
false
hat.
Parameter
| Operand | - |
Zielobjekt
any
|
Rückgabewert
1)
Gibt
*
any_cast
<
std::
add_const_t
<
std::
remove_reference_t
<
ValueType
>>>
(
&
operand
)
zurück.
2,3)
Gibt
*
any_cast
<
std::
remove_reference_t
<
ValueType
>>
(
&
operand
)
zurück.
4,5)
Falls
operand
kein Nullzeiger ist und die
typeid
des angeforderten
ValueType
mit der des Inhalts von
operand
übereinstimmt, ein Zeiger auf den in
operand
enthaltenen Wert, andernfalls ein Nullzeiger.
Exceptions
1-3)
Wirft
bad_any_cast
, falls die
typeid
des angeforderten
ValueType
nicht mit der des Inhalts von
operand
übereinstimmt.