memory_allocator_arg_t

memory_allocator_arg_t (std::allocator_arg_t)

<memory> 헤더에 정의되어 있어요. 할당자 인식(allocator-aware) 객체의 생성자와 멤버 함수의 오버로드를 구분하기 위해 쓰는 빈 클래스 타입이에요. C++11부터 도입됐어요.

출처: cppreference

본문

struct allocator_arg_t { explicit allocator_arg_t() = default; };   // (1) since C++11

constexpr std::allocator_arg_t allocator_arg {};   // (2) since C++11, inline since C++17
    1. std::allocator_arg_t는 할당자 인식 객체(예: std::tuple, std::function, std::packaged_task(C++17 이전), std::promise)의 생성자와 멤버 함수의 오버로드를 구분하는 데 쓰는 빈 클래스 타입이에요.
    1. std::allocator_arg는 (1)의 인스턴스로, 그런 허용 타입의 생성자와 멤버 함수에 전달할 수 있어요.

결함 보고 (Defect reports)

이후 확정된 표준에 소급 적용된 결함 보고가 있어요. LWG 2510은 C++11에서 기본 생성자가 비-explicit여서 모호성이 생길 수 있었던 것을 explicit으로 만들었어요.

할당자 인식 컨테이너들에서, 첫 인자로 std::allocator_arg를 넘기면 그 뒤 인자들이 실제 객체 생성 인자임을 알리고, 이어서 할당자를 별도로 넘길 수 있어요.

std::pmr::vector<int> v(std::allocator_arg, my_allocator, 10);

더 알아보기 (Learn more)

cppreference