Namespaces
Variants

std::allocator_traits<Alloc>:: 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)
헤더에 정의됨 <memory>
template < class T, class ... Args >
static void construct ( Alloc & a, T * p, Args && ... args ) ;
(C++11 이후)
(C++20 이후 constexpr)

가능하다면, 할당된 초기화되지 않은 저장 공간에서 T 타입의 객체를 p 가 가리키는 위치에 생성합니다. 이는 a. construct ( p, std:: forward < Args > ( args ) ... ) 를 호출하여 수행됩니다.

위의 작업이 불가능한 경우(예: Alloc construct() 멤버 함수가 없는 경우), 다음을 호출합니다

:: new ( static_cast < void * > ( p ) ) T ( std:: forward < Args > ( args ) ... )

(C++20 이전)

std:: construct_at ( p, std:: forward < Args > ( args ) ... )

(C++20 이후)

목차

매개변수

a - 객체 생성에 사용할 할당자
p - T 객체가 생성될 초기화되지 않은 저장 공간을 가리키는 포인터
args... - a. construct ( ) 또는 placement-new (until C++20) std::construct_at() (since C++20) 에 전달할 생성자 인자들

반환값

(없음)

참고 사항

이 함수는 표준 라이브러리 컨테이너가 요소를 삽입, 복사 또는 이동할 때 사용됩니다.

이 함수는 자동으로 placement new로 대체되므로, 멤버 함수 construct() 는 C++11부터 선택적인 Allocator 요구 사항입니다.

참고 항목

할당 함수
(함수)
(C++20 이전)
할당된 저장 공간에 객체를 생성함
( std::allocator<T> 의 public member function)
주어진 주소에 객체를 생성함
(함수 템플릿)