Namespaces
Variants

std::experimental::pmr::polymorphic_allocator<T>:: construct

From cppreference.net
template < class U, class ... Args >
void construct ( U * p, Args && ... args ) ;
(1) (라이브러리 fundamentals TS)
template < class T1, class T2, class ... Args1 , class ... Args2 >

void construct ( std:: pair < T1, T2 > * p,
std:: piecewise_construct_t ,
std:: tuple < Args1... > x,

std:: tuple < Args2... > y ) ;
(2) (라이브러리 fundamentals TS)
template < class T1, class T2 >
void construct ( std:: pair < T1, T2 > * p ) ;
(3) (라이브러리 fundamentals TS)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, U && x, V && y ) ;
(4) (라이브러리 fundamentals TS)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, const std:: pair < U, V > & xy ) ;
(5) (라이브러리 fundamentals TS)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, std:: pair < U, V > && xy ) ;
(6) (라이브러리 fundamentals TS)

할당되었지만 초기화되지 않은 저장 공간에 객체를 생성합니다. 이 저장 공간은 p 가 가리키며, 제공된 생성자 인자를 사용합니다. 객체가 자체적으로 할당자를 사용하는 타입이거나 std::pair인 경우, this->resource() 를 생성된 객체에 전달합니다.

1) 만약 std:: uses_allocator < U, memory_resource * > :: value == false (타입 U 가 할당자를 사용하지 않음)이고 std:: is_constructible < U, Args... > :: value == true 인 경우, 다음처럼 객체를 생성합니다 :: new ( ( void * ) p ) U ( std:: forward < Args > ( args ) ... ) ; .

그렇지 않고 만약 std:: uses_allocator < U, memory_resource * > :: value == true (타입 U 가 할당자를 사용하는 경우, 예를 들어 컨테이너인 경우) 그리고 std:: is_constructible < U, std:: allocator_arg_t , memory_resource * , Args... > :: value == true 인 경우, 다음처럼 객체를 생성합니다: :: new ( ( void * ) p ) U ( std:: allocator_arg , this - > resource ( ) , std:: forward < Args > ( args ) ... ) ; .

그렇지 않고, std:: uses_allocator < U, memory_resource * > :: value == true (타입 U 가 할당자를 사용하는 경우, 예를 들어 컨테이너인 경우)이고 std:: is_constructible < U, Args..., memory_resource * > :: value == true 인 경우, 객체를 다음과 같이 생성합니다: :: new ( ( void * ) p ) U ( std:: forward < Args > ( args ) ..., this - > resource ( ) ) ; .

그렇지 않으면, 프로그램이 형식 오류를 갖습니다.

2) 먼저, T1 또는 T2 중 하나라도 allocator-aware인 경우, 다음 세 가지 규칙에 따라 this->resource() 를 포함하도록 튜플 x y 를 수정하여 두 개의 새로운 튜플 xprime yprime 를 생성합니다:

2a) 만약 T1 이 allocator-aware가 아니고 ( std:: uses_allocator < T1, memory_resource * > :: value == false ) 그리고 std:: is_constructible < T1, Args1... > :: value == true 라면, xprime x 로, 수정되지 않은 상태입니다.

2b) 만약 T1 이 allocator-aware이고 ( std:: uses_allocator < T1, memory_resource * > :: value == true ), 그리고 해당 생성자가 allocator 태그를 받는 경우 ( std:: is_constructible < T1, std:: allocator_arg_t , memory_resource * , Args1... > :: value == true ), 그러면 xprime std:: tuple_cat ( std:: make_tuple ( std:: allocator_arg , this - > resource ( ) ) , std :: move ( x ) ) 입니다.

2c) 만약 T1 이 allocator-aware라면 ( std:: uses_allocator < T1, memory_resource * > :: value == true ), 그리고 해당 생성자가 마지막 인자로 allocator를 받는다면 ( std:: is_constructible < T1, Args1..., memory_resource * > :: value == true ), 그러면 xprime std:: tuple_cat ( std :: move ( x ) , std:: make_tuple ( this - > resource ( ) ) ) 입니다.

2d) 그렇지 않으면, 프로그램은 형식이 잘못되었습니다(ill-formed).

동일한 규칙이 T2 y yprime 로의 대체에도 적용됩니다.

xprime yprime 이 생성된 후, 할당된 저장 공간에 다음과 같이 p 쌍을 생성합니다: :: new ( ( void * ) p ) pair < T1, T2 > ( std:: piecewise_construct , std :: move ( xprime ) , std :: move ( yprime ) ) ; .

3) 다음에 해당함: construct ( p, std:: piecewise_construct , std:: tuple <> ( ) , std:: tuple <> ( ) ) , 즉, 메모리 리소스를 pair의 멤버 타입이 이를 수용할 경우 해당 타입에 전달합니다.

4) 다음에 해당함

construct ( p, std:: piecewise_construct , std:: forward_as_tuple ( std:: forward < U > ( x ) ) ,
std:: forward_as_tuple ( std:: forward < V > ( y ) ) )

5) 다음에 해당함

construct ( p, std:: piecewise_construct , std:: forward_as_tuple ( xy. first ) ,
std:: forward_as_tuple ( xy. second ) )

6) 다음과 동일함

construct ( p, std:: piecewise_construct , std:: forward_as_tuple ( std:: forward < U > ( xy. first ) ) ,
std:: forward_as_tuple ( std:: forward < V > ( xy. second ) ) )

목차

매개변수

p - 할당되었지만 초기화되지 않은 저장 공간에 대한 포인터
args... - T 의 생성자에 전달할 생성자 인수
x - T1 의 생성자에 전달할 생성자 인수
y - T2 의 생성자에 전달할 생성자 인수
xy - 두 멤버가 각각 T1 T2 의 생성자 인수인 pair

반환값

(없음)

참고 사항

이 함수는 ( std::allocator_traits 를 통해) 할당자 인식 객체(예: std::vector )가 사용할 할당자로 std::polymorphic_allocator 를 전달받은 경우 호출됩니다. memory_resource* polymorphic_allocator 로 암시적으로 변환되므로, 메모리 리소스 포인터는 다형적 할당자를 사용하는 모든 할당자 인식 하위 객체로 전파됩니다.

참고 항목

[static]
할당된 저장 공간에 객체를 생성함
(함수 템플릿)
(C++20까지)
할당된 저장 공간에 객체를 생성함
( std::allocator<T> 의 public 멤버 함수)