std:: uses_allocator_construction_args
|
헤더에 정의됨
<memory>
|
||
T
는
std::pair
의 특수화가 아닙니다
|
||
|
template
<
class
T,
class
Alloc,
class
...
Args
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(1) | (C++20부터) |
T
는
std::pair
의 특수화입니다
|
||
|
template
<
class
T,
class
Alloc,
class
Tuple1,
class
Tuple2
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(2) | (C++20 이후) |
|
template
<
class
T,
class
Alloc
>
constexpr auto uses_allocator_construction_args ( const Alloc & alloc ) noexcept ; |
(3) | (C++20 이후) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(4) | (C++20 이후) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(5) | (C++23 이후) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(6) | (C++20 이후) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(7) | (C++20 이후) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(8) | (C++23 이후) |
|
template
<
class
T,
class
Alloc,
class
NonPair
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(9) | (C++20 이후) |
주어진 타입
T
의 객체를
uses-allocator construction
을 통해 생성하는 데 필요한 인수 목록을 준비합니다.
T
가
std::pair
의 특수화가 아닌 경우에만 오버로드 해결에 참여합니다. 다음과 같이 결정된
std::tuple
을 반환합니다:
- 만약 std:: uses_allocator_v < T, Alloc > 가 false 이고 std:: is_constructible_v < T, Args... > 가 true 인 경우, std:: forward_as_tuple ( std:: forward < Args > ( args ) ... ) 를 반환합니다.
-
그렇지 않고
std::
uses_allocator_v
<
T, Alloc
>
가
true
이고
std::
is_constructible_v
<
T,
std::
allocator_arg_t
,
const
Alloc
&
, Args...
>
가
true
인 경우,
std:: tuple < std:: allocator_arg_t , const Alloc & , Args && ... > ( std:: allocator_arg , alloc,
std:: forward < Args > ( args ) ... ) 를 반환합니다. - 그렇지 않고 std:: uses_allocator_v < T, Alloc > 가 true 이고 std:: is_constructible_v < T, Args..., const Alloc & > 가 true 인 경우, std:: forward_as_tuple ( std:: forward < Args > ( args ) ..., alloc ) 를 반환합니다.
- 그렇지 않으면 프로그램은 형식이 잘못되었습니다.
T
가
std::pair
의 특수화인 경우에만 오버로드 해결에 참여합니다.
T
가
std::
pair
<
T1, T2
>
인 경우, 다음 코드와 동등합니다:
return std::make_tuple(std::piecewise_construct, std::apply([&alloc](auto&&... args1) { return std::uses_allocator_construction_args<T1>(alloc, std::forward<decltype(args1)>(args1)...); }, std::forward<Tuple1>(x) ), std::apply([&alloc](auto&&... args2) { return std::uses_allocator_construction_args<T2>(alloc, std::forward<decltype(args2)>(args2)...); }, std::forward<Tuple2>(y) ) );
T
가
std::pair
의 특수화인 경우. 다음 코드와 동일합니다:
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::tuple<>{}, std::tuple<>{} );
T
가
std::pair
의 특수화(specialization)인 경우에만 오버로드 해결에 참여합니다. 다음 코드와 동일합니다:
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple(std::forward<U>(u)), std::forward_as_tuple(std::forward<V>(v)) );
T
가
std::pair
의 특수화인 경우에만 오버로드 해결에 참여합니다. 다음 코드와 동일합니다:
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple(pr.first), std::forward_as_tuple(pr.second) );
T
가
std::pair
의 특수화(specialization)인 경우에만 오버로드 해결에 참여합니다. 다음 코드와 동일합니다:
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::forward_as_tuple(std::get<0>(std::move(pr))), std::forward_as_tuple(std::get<1>(std::move(pr))) );
T
가
std::pair
의 특수화(specialization)이고, 주어진 설명 전용(exposition-only) 함수 템플릿
template<class A, class B> void /*deduce-as-pair*/(const std::pair<A, B>&);
에 대해,
/*deduce-as-pair*/
(
non_pair
)
가 평가되지 않은 피연산자로 고려될 때 형식이 잘못되었을 경우입니다.
설명 전용 클래스
pair-constructor
를 다음과 같이 정의합니다:
class /*pair-constructor*/ { const Alloc& alloc_; // exposition only NonPair& u_; // exposition only constexpr reconstruct(const std::remove_cv<T>& p) const // exposition only { return std::make_obj_using_allocator<std::remove_cv<T>>(alloc_, p); } constexpr reconstruct(std::remove_cv<T>&& p) const // exposition only { return std::make_obj_using_allocator<std::remove_cv<T>>(alloc_, std::move(p)); } public: constexpr operator std::remove_cv<T>() const { return reconstruct(std::forward<NonPair>(u_)); } };
pair_construction
는
pair-constructor
타입의 값이며, 그
alloc_
과
u_
멤버는 각각
alloc
과
non_pair
입니다.
목차 |
매개변수
| alloc | - | 사용할 할당자 |
| args | - |
T
의 생성자에 전달할 인수들
|
| x | - |
T
의
first
데이터 멤버 생성자에 전달할 인수들의 튜플
|
| y | - |
T
의
second
데이터 멤버 생성자에 전달할 인수들의 튜플
|
| u | - |
T
의
first
데이터 멤버 생성자에 전달할 단일 인수
|
| v | - |
T
의
second
데이터 멤버 생성자에 전달할 단일 인수
|
| pr | - |
first
데이터 멤버가
T
의
first
데이터 멤버 생성자에 전달되고
second
데이터 멤버가
T
의
second
데이터 멤버 생성자에 전달될 pair
|
| non_pair | - | 추가적인 생성을 위해 std::pair 로 변환할 단일 인수 |
반환값
std::tuple
을
T
의 생성자에 전달하기 적합한 인수들로 구성합니다.
참고 사항
오버로드 (2-9) 는 allocator propagation을 std::pair 에 제공하며, 이는 leading-allocator나 trailing-allocator 호출 규약을 지원하지 않습니다 (예를 들어 leading-allocator 규약을 사용하는 std::tuple 과는 다릅니다).
uses-allocator construction에서 사용될 때,
pair-constructor
의 변환 함수는 먼저 제공된 인수를
std::pair
로 변환한 다음, 해당
std::pair
로부터 uses-allocator construction을 통해 결과를 생성합니다.
예제
|
이 섹션은 불완전합니다
이유: 예제 없음 |
결함 보고서
다음 동작 변경 결함 보고서는 이전에 게시된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 3525 | C++20 |
pair
로 변환 가능한 non-
pair
타입을 처리할 수 있는 오버로드가 없음
|
재구성 오버로드 추가됨 |
참고 항목
|
(C++11)
|
지정된 타입이 uses-allocator construction을 지원하는지 확인합니다
(클래스 템플릿) |
|
(C++20)
|
uses-allocator construction을 통해 주어진 타입의 객체를 생성합니다
(함수 템플릿) |
|
uses-allocator construction을 통해 지정된 메모리 위치에 주어진 타입의 객체를 생성합니다
(함수 템플릿) |