memory_make_obj_using_allocator
memory_make_obj_using_allocator (std::make_obj_using_allocator)
<memory> 헤더에 정의되어 있어요. uses-allocator construction(할당자 인식 생성)을 통해 주어진 타입 T의 객체를 생성해요. C++20부터 도입됐어요.
출처: cppreference
본문
template< class T, class Alloc, class... Args >
constexpr T make_obj_using_allocator( const Alloc& alloc, Args&&... args );
(C++20부터)
uses-allocator construction을 통해 주어진 타입 T의 객체를 생성해요. 다음과 동등해요.
return std::make_from_tuple<T>(
std::uses_allocator_construction_args<T>(alloc, std::forward<Args>(args)...)
);
매개변수
alloc: 사용할 할당자args:T의 생성자에 전달할 인자들
반환값
새로 생성된 T 타입 객체.
예외
T의 생성자가 던지는 예외를 던질 수 있고, 보통 std::bad_alloc을 포함해요.
이 함수는 할당자 인식 타입(할당자를 이용해 내부 저장 공간을 만드는 타입)을 생성할 때 할당자를 올바르게 전달하면서 객체를 만들 때 사용해요.
// allocator-aware 타입 T 를 alloc 로 생성
T obj = std::make_obj_using_allocator<T>(alloc, arg1, arg2);