std:: uses_allocator
|
헤더에 정의됨
<memory>
|
||
|
template
<
class
T,
class
Alloc
>
struct uses_allocator ; |
(C++11 이후) | |
만약
T
가
Alloc
으로부터 변환 가능한 중첩 타입
allocator_type
을 가지고 있다면, 멤버 상수
value
는
true
입니다. 그렇지 않으면
value
는
false
입니다.
목차 |
헬퍼 변수 템플릿
|
template
<
class
T,
class
Alloc
>
constexpr bool uses_allocator_v = uses_allocator < T, Alloc > :: value ; |
(C++17부터) | |
std:: integral_constant 에서 상속됨
멤버 상수
|
value
[static]
|
true
만약
T
가 할당자
Alloc
를 사용하면,
false
그렇지 않으면
(public static member constant) |
멤버 함수
|
operator bool
|
객체를
bool
로 변환,
value
반환
(public member function) |
|
operator()
(C++14)
|
value
반환
(public member function) |
멤버 타입
| 타입 | 정의 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
Uses-allocator construction
allocator를 어떤 타입
T
의 생성자에 전달하는 세 가지 관례가 있습니다:
-
만약
T가 호환되는 할당자를 사용하지 않는 경우 ( std :: uses_allocator_v < T, Alloc > 가 false 인 경우),alloc은 무시됩니다. - 그렇지 않은 경우, std :: uses_allocator_v < T, Alloc > 가 true 이고,
-
-
만약
T가 선행-할당자 규약 을 사용하는 경우( T ( std:: allocator_arg , alloc, args... ) 로 호출 가능할 때), uses-allocator construction은 이 형식을 사용합니다. -
만약
T가 후행-할당자 규약 을 사용하는 경우( T ( args..., alloc ) 로 호출 가능할 때), uses-allocator construction은 이 형식을 사용합니다. - 그렇지 않으면 프로그램은 ill-formed입니다 (이는 std :: uses_allocator_v < T, Alloc > 가 true 이지만, 해당 타입이 허용된 두 규약 중 어느 것도 따르지 않음을 의미합니다).
-
만약
-
특별한 경우로,
std::pair
는 쌍에 대해
std::uses_allocator가 false 임에도 불구하고(예: std::tuple 과 달리) uses-allocator 타입으로 취급됩니다: std::pmr::polymorphic_allocator::construct 및 std::scoped_allocator_adaptor::construct (C++20 이전) std::uses_allocator_construction_args (C++20 이후) 의 쌍 특화 오버로드를 참조하십시오.
|
유틸리티 함수들 std::make_obj_using_allocator 과 std::uninitialized_construct_using_allocator 는 위 프로토콜에 따라 객체를 명시적으로 생성하는 데 사용될 수 있으며, std::uses_allocator_construction_args 는 해당 타입이 예상하는 uses-allocator construction 방식과 일치하는 인수 목록을 준비하는 데 사용될 수 있습니다. |
(C++20부터) |
특수화
프로그램 정의 타입
T
에 중첩된
allocator_type
가 없는 경우, 프로그램은 다음 요구 사항 중 하나라도 충족되면
T
에 대해
std::uses_allocator
의 특수화를
std::true_type
에서 파생하도록 지정할 수 있습니다:
-
T는 첫 번째 인자로 std::allocator_arg_t 를, 두 번째 인자로Alloc을 받는 생성자를 가지고 있습니다. -
T는 마지막 인자로Alloc을 받는 생성자를 가지고 있습니다.
위에서,
Alloc
은 다음을 만족하는 타입입니다:
Allocator
또는
std::experimental::pmr::memory_resource*
로 변환 가능한 포인터 타입입니다
(library fundamentals TS)
.
다음 특수화들은 표준 라이브러리에서 이미 제공됩니다:
|
(C++11)
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
(C++11)
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
|
(C++11)
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
|
(C++11)
(until C++17)
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
|
|
(C++11)
(until C++17)
|
std::uses_allocator
타입 특성의 특수화
(클래스 템플릿 특수화) |
참고 사항
이 타입 특성은 std::tuple , std::scoped_allocator_adaptor , 그리고 std::pmr::polymorphic_allocator 에 의해 사용됩니다. 또한 커스텀 할당자나 래퍼 타입에 의해 객체나 구성 중인 멤버가 자체적으로 할당자를 사용할 수 있는지(예: 컨테이너인 경우) 여부를 판단하는 데 사용될 수 있으며, 이 경우 해당 생성자에 할당자를 전달해야 합니다.
참고 항목
|
(C++11)
|
할당자 인식 생성자를 선택하는 데 사용되는 태그
(tag) |
|
(C++20)
|
주어진 타입에 필요한 uses-allocator 생성 방식에 맞는 인수 목록을 준비함
(function template) |
|
(C++20)
|
uses-allocator 생성 방식을 통해 주어진 타입의 객체를 생성함
(function template) |
|
지정된 메모리 위치에서 uses-allocator 생성 방식을 통해 주어진 타입의 객체를 생성함
(function template) |
|
|
(C++11)
|
다중 수준 컨테이너를 위한 다중 수준 할당자를 구현함
(class template) |