std::expected<T,E>::emplace
ko.cppreference.net 소개
| 기본 템플릿 |
||
template< class... Args >
constexpr T& emplace( Args&&... args ) noexcept;
|
(1) | (C++23부터) |
template< class U, class... Args >
constexpr T& emplace( std::initializer_list<U> il, Args&&... args ) noexcept;
|
(2) | (C++23부터) |
void 부분 특수화 |
||
constexpr void emplace() noexcept;
|
(3) | (C++23부터) |
기대값(expected value)을 제자리에서 생성합니다. 이 호출 후 has_value()는 true를 반환합니다.
이 오버로드는
std::is_nothrow_constructible_v<T, Args...>이 true인 경우에만 오버로드 해결에 참여합니다.2) 포함된 값을 소멸시킨 후, 직접 초기화를 사용하여
*this에 포함된 기대값을 il과 std::forward<Args>(args)...로 초기화합니다. 이 오버로드는
std::is_nothrow_constructible_v<T, std::initializer_list<U>&, Args...>이 true인 경우에만 오버로드 해결에 참여합니다.3)
*this이 예상치 못한 값(unexpected value)을 포함하고 있으면, 그 값을 소멸시킵니다.매개변수
| args | - | 생성자에 전달할 인수 |
| il | - | 생성자에 전달할 초기화 리스트 |
반환값
1)
*
std::
construct_at
(
std::
addressof
(
val
)
,
std::
forward
<
Args
>
(
args
)
...
)
2)
*
std::
construct_at
(
std::
addressof
(
val
)
, il,
std::
forward
<
Args
>
(
args
)
...
)
참고 사항
T
의 생성이 잠재적으로 예외를 발생시킬 수 있는 경우,
operator=
를 대신 사용할 수 있습니다.
예제
|
이 섹션은 불완전합니다
이유: 예제가 없음 |
참고 항목
|
내용을 할당
(public member function) |