std::experimental:: any_cast
From cppreference.net
<
cpp
|
experimental
|
any
|
template
<
class
ValueType
>
ValueType any_cast ( const any & operand ) ; |
(1) | (라이브러리 fundamentals TS) |
|
template
<
class
ValueType
>
ValueType any_cast ( any & operand ) ; |
(2) | (라이브러리 fundamentals TS) |
|
template
<
class
ValueType
>
ValueType any_cast ( any && operand ) ; |
(3) | (라이브러리 fundamentals TS) |
|
template
<
class
ValueType
>
const ValueType * any_cast ( const any * operand ) noexcept ; |
(4) | (라이브러리 fundamentals TS) |
|
template
<
class
ValueType
>
ValueType * any_cast ( any * operand ) noexcept ; |
(5) | (라이브러리 fundamentals TS) |
포함된 객체에 대해 타입 안전 접근을 수행합니다.
(1-3)
의 경우,
ValueType
이 참조가 아니고
std::
is_copy_constructible
<
ValueType
>
::
value
가
false
이면 프로그램의 형식이 올바르지 않습니다.
매개변수
| 피연산자 | - |
대상
any
객체
|
반환값
1)
*
any_cast
<
std::
add_const_t
<
std::
remove_reference_t
<
ValueType
>>>
(
&
operand
)
을 반환합니다.
2,3)
반환값
*
any_cast
<
std::
remove_reference_t
<
ValueType
>>
(
&
operand
)
.
4,5)
만약
operand
가 null 포인터가 아니고, 요청된
typeid
가
operand
의 내용과 일치하는
ValueType
인 경우,
operand
가 포함하는 값에 대한 포인터를 반환하고, 그렇지 않으면 null 포인터를 반환합니다.
예외
1-3)
operand
의 내용과 요청된
ValueType
의
typeid
가 일치하지 않으면
bad_any_cast
를 throw합니다.