Namespaces
Variants

std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>:: construct

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
헤더에 정의됨 <scoped_allocator>
template < class T, class ... Args >
void construct ( T * p, Args && ... args ) ;
(1)
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) (C++20 이전)
template < class T1, class T2 >
void construct ( std:: pair < T1, T2 > * p ) ;
(3) (C++20 이전)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, U && x, V && y ) ;
(4) (C++20 이전)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, const std:: pair < U, V > & xy ) ;
(5) (C++20까지)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, std:: pair < U, V > && xy ) ;
(6) (C++20까지)
헬퍼 함수 템플릿
template < class T, class ... Args >
std:: tuple < /* see below */ > /*concat-args*/ ( std:: tuple < Args... > && tup ) ;
(7) ( 설명 전용* )
(C++20 이전)

할당되었지만 초기화되지 않은 저장 공간을 가리키는 p 에서 외부 할당자와 제공된 생성자 인수를 사용하여 객체를 생성합니다. 객체 자체가 할당자를 사용하는 타입인 경우 , 또는 std::pair 인 경우 (C++20 이전) , 내부 할당자를 생성된 객체에 전달합니다.

1) Constructs an object of type T by uses-allocator construction at the uninitialized memory location indicated by p using the outermost allocator.

std:: uses_allocator < T, inner_allocator_type > :: value uses_inner 로 주어졌을 때:

이 오버로드는 T std::pair 의 특수화가 아닌 경우에만 오버로드 해결에 참여합니다.

(C++20 이전)

다음 코드와 동등합니다: std:: apply
(
[ p, this ] ( auto && ... newargs )
{
outermost-construct
( p, std:: forward < decltype ( newargs ) > ( newargs ) ... ) ;
} ,
std:: uses_allocator_construction_args
( inner_allocator ( ) , std:: forward < Args > ( args ) ... )
) ;
.

(C++20부터)
2-6) 지정된 미초기화 메모리 위치 p 에서 최외각 할당자를 사용하여 사용자-할당자 생성 을 통해 std::pair 객체를 생성합니다.
2) xprime concat-args  < T1 > ( std :: move ( x ) ) 로, yprime concat-args  < T2 > ( std :: move ( y ) ) 로 정의하고, outermost-construct  ( p, std:: piecewise_construct , std :: move ( xprime ) , std :: move ( yprime ) ) 를 호출합니다.
3) 다음에 해당함 construct ( p, std:: piecewise_construct , std:: tuple <> ( ) , std:: tuple <> ( ) ) ; .
4-6) 다음 코드와 동등합니다: construct ( p, std:: piecewise_construct ,
std:: forward_as_tuple ( xarg ) , std:: forward_as_tuple ( yarg ) ) ;
, 여기서 xarg yarg 는 다음과 같이 정의됩니다:
오버로드 xarg yarg
(4) std:: forward < U > ( x ) std:: forward < V > ( y )
(5) xy. first xy. second
(6) std:: forward < U > ( xy. first ) std:: forward < V > ( xy. second )
7) tup 에 포함된 인자들과 T 타입 객체의 uses-allocator construction 에 필요한 추가 인자들을 병합합니다.
주어진 std:: uses_allocator < T, inner_allocator_type > :: value uses_inner 로 할 때:

목차

매개변수

p - 할당되었지만 초기화되지 않은 저장 공간을 가리키는 포인터
args - T 의 생성자에 전달할 생성자 인수
x - T1 의 생성자에 전달할 생성자 인수
y - T2 의 생성자에 전달할 생성자 인수
xy - 두 멤버가 각각 T1 T2 의 생성자 인수인 pair
tup - 병합될 인수들

참고 사항

이 함수는 ( std::allocator_traits 를 통해) 할당자 인식 객체(예: std::vector )가 사용할 할당자로 std::scoped_allocator_adaptor 가 주어졌을 때 호출됩니다. inner_allocator_type 자체가 std::scoped_allocator_adaptor 의 특수화이기 때문에, 이 함수를 통해 생성된 할당자 인식 객체들이 자신의 멤버들을 생성하기 시작할 때에도 이 함수가 호출됩니다.

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2203 C++11 내부 할당자를 값 초기화된
inner_allocator_type 객체로 획득
inner_allocator() 호출로 획득
LWG 2511
( P0475R1 )
C++11 concat-args std::tuple 의 요소들을 복사할 수 있음 모든 요소 복사 연산 제거
LWG 2586 C++11 inner_allocator_type rvalue로부터의 생성만 검사됨 비상수 inner_allocator_type lvalue로부터의 생성 검사로 대체
LWG 2975 C++11 오버로드 (1) 이 제약되지 않음 std::pair 를 거부하도록 제약됨

참고 항목

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