Namespaces
Variants

std::expected<T,E>:: emplace

From cppreference.net
Utilities library
기본 템플릿
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를 반환합니다.

1) 포함된 값을 파괴한 다음, 직접 초기화 를 통해 * this 에 포함된 expected 값을 std:: forward < Args > ( args ) ... 로 초기화합니다.
이 오버로드는 std:: is_nothrow_constructible_v < T, Args... > true 인 경우에만 오버로드 해결에 참여합니다.
2) 포함된 값을 파괴한 후, * this 에 포함된 expected 값을 il std:: forward < Args > ( args ) ... 로 직접 초기화합니다.
이 오버로드는 다음 조건이 std:: is_nothrow_constructible_v < T, std:: initializer_list < U > & , Args... > 일 때에만 오버로드 해결에 참여합니다.
3) 만약 * this 가 예상치 못한 값을 포함하고 있다면, 해당 값을 파괴합니다.

목차

매개변수

args - 생성자에 전달할 인수
il - 생성자에 전달할 초기화 리스트

반환값

2) * std:: construct_at ( std:: addressof ( val ) , il, std:: forward < Args > ( args ) ... )

참고 사항

T 의 생성이 잠재적으로 예외를 발생시킬 수 있는 경우, operator= 를 대신 사용할 수 있습니다.

예제

참고 항목

내용을 할당
(public member function)