allocator_arg — std::allocator_arg

allocator_arg — std::allocator_arg

std::allocator_arg할당자 인식(allocator-aware) 생성자에서 할당자를 인자로 전달할 때, 일반 인자와 구분하기 위해 쓰는 태그(tag) 객체예요. std::allocator_arg_t 타입의 인스턴스예요.

예를 들어 std::vectorstd::set 같은 할당자 인식 컨테이너를 "이 할당자로 만들어줘"라고 할 때, 다른 생성 인자와 섞이지 않도록 std::allocator_arg 태그를 먼저 넘겨요.

출처: cppreference

본문

std::allocator_argstd::allocator_arg_t 타입의 상수 인스턴스예요.

inline constexpr allocator_arg_t allocator_arg{};

이는 할당자 인식 생성자가 할당자와 다른 인자를 구분해 받을 수 있게 하는 태그로 사용돼요. allocator_arg_t 타입을 첫 번째 인자로 받는 생성자는 "할당자를 명시적으로 제공"한다는 뜻이에요.

같이 보기

  • std::allocator_arg_t
  • 할당자(allocator) 개념
  • uses_allocator

더 알아보기 (Learn more)

cppreference