Namespaces
Variants

std:: uses_allocator_construction_args

From cppreference.net
Memory management library
( exposition only* )
Allocators
uses_allocator_construction_args
(C++20)
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
헤더에 정의됨 <memory>
T std::pair 의 특수화가 아닙니다
template < class T, class Alloc, class ... Args >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

Args && ... args ) noexcept ;
(1) (C++20부터)
T std::pair 의 특수화입니다
template < class T, class Alloc, class Tuple1, class Tuple2 >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

std:: piecewise_construct_t , Tuple1 && x, Tuple2 && y ) noexcept ;
(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,

U && u, V && v ) noexcept ;
(4) (C++20 이후)
template < class T, class Alloc, class U, class V >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

std:: pair < U, V > & pr ) noexcept ;
(5) (C++23 이후)
template < class T, class Alloc, class U, class V >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

const std:: pair < U, V > & pr ) noexcept ;
(6) (C++20 이후)
template < class T, class Alloc, class U, class V >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

std:: pair < U, V > && pr ) noexcept ;
(7) (C++20 이후)
template < class T, class Alloc, class U, class V >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

const std:: pair < U, V > && pr ) noexcept ;
(8) (C++23 이후)
template < class T, class Alloc, class NonPair >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

NonPair && non_pair ) noexcept ;
(9) (C++20 이후)

주어진 타입 T 의 객체를 uses-allocator construction 을 통해 생성하는 데 필요한 인수 목록을 준비합니다.

1) 이 오버로드는 T std::pair 의 특수화가 아닌 경우에만 오버로드 해결에 참여합니다. 다음과 같이 결정된 std::tuple 을 반환합니다:
2) 이 오버로드는 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)
    )
);
3) 이 오버로드는 다음 조건에서만 오버로드 해결에 참여합니다: T std::pair 의 특수화인 경우. 다음 코드와 동일합니다:
return std::uses_allocator_construction_args<T>(alloc,
    std::piecewise_construct, std::tuple<>{}, std::tuple<>{}
);
4) 이 오버로드는 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))
);
5,6) 이 오버로드는 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)
);
7,8) 이 오버로드는 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)))
);
9) 이 오버로드는 다음 조건에서만 오버로드 해결에 참여합니다: 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_));
    }
};
이 오버로드는 다음 코드와 동등합니다: return std:: make_tuple ( pair_construction ) ; , 여기서 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 타입을 처리할 수 있는 오버로드가 없음 재구성 오버로드 추가됨

참고 항목

지정된 타입이 uses-allocator construction을 지원하는지 확인합니다
(클래스 템플릿)
uses-allocator construction을 통해 주어진 타입의 객체를 생성합니다
(함수 템플릿)
uses-allocator construction을 통해 지정된 메모리 위치에 주어진 타입의 객체를 생성합니다
(함수 템플릿)