Namespaces
Variants
Views
Actions

std::uses_allocator_construction_args

From cppreference.com
< cpp‎ | memory
 
 
 
Dynamic memory management
Uninitialized storage
(C++17)
Garbage collection support
Miscellaneous
(C++20)
(C++11)
(C++11)
C Library
Low level memory management
 
Defined in header <memory>
T is not a specialization of std::pair
template< class T, class Alloc, class... Args >

constexpr std::tuple</*see below*/> uses_allocator_construction_args(

    const Alloc& alloc, Args&&... args) noexcept;
(1) (since C++20)
T is a specialization of std::pair
template< class T, class Alloc, class Tuple1, class Tuple2 >

constexpr std::tuple</*see below*/> uses_allocator_construction_args(

    const Alloc& alloc, std::piecewise_construct_t, Tuple1&& x, Tuple2&& y) noexcept;
(2) (since C++20)
template< class T, class Alloc >

constexpr std::tuple</*see below*/> uses_allocator_construction_args(

    const Alloc& alloc ) noexcept;
(3) (since C++20)
template< class T, class Alloc, class U, class V >

constexpr std::tuple</*see below*/> uses_allocator_construction_args(

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

constexpr std::tuple</*see below*/> uses_allocator_construction_args(

    const Alloc& alloc, const std::pair<U,V>& pr) noexcept;
(5) (since C++20)
template< class T, class Alloc, class U, class V >

constexpr std::tuple</*see below*/> uses_allocator_construction_args(

    const Alloc& alloc, std::pair<U,V>&& pr) noexcept;
(6) (since C++20)

Prepares the argument list needed to create an object of the given type T by means of uses-allocator construction.

1) This overload only participates in overload resolution if T is not a specialization of std::pair. Returns std::tuple determined as follows:
2) This overload only participates in overload resolution if T is a specialization of std::pair. For T = std::pair<T1, T2>, equivalent to
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) This overload only participates in overload resolution if T is a specialization of std::pair. Equivalent to
return std::uses_allocator_construction_args<T>(alloc,
    std::piecewise_construct, std::tuple<>{}, std::tuple<>{}
);
4) This overload only participates in overload resolution if T is a specialization of std::pair. Equivalent to
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) This overload only participates in overload resolution if T is a specialization of std::pair. Equivalent to
return std::uses_allocator_construction_args<T>( alloc,
    std::piecewise_construct,
    std::forward_as_tuple(pr.first),
    std::forward_as_tuple(pr.second)
);
6) This overload only participates in overload resolution if T is a specialization of std::pair. Equivalent to
return std::uses_allocator_construction_args<T>( alloc,
    std::piecewise_construct,
    std::forward_as_tuple(std::move(pr).first),
    std::forward_as_tuple(std::move(pr).second));

Contents

[edit] Parameters

alloc - the allocator to use.
args - the arguments to pass to T's constructor
x - tuple of arguments to pass to the constructors of T's .first
y - tuple of arguments to pass to the constructors of T's .second
u - single argument to pass to the constructor of T's .first
v - single argument to pass to the constructor of T's .second
pr - a pair whose .first will be passed to the constructor of T's .first and .second will be passed to the constructor of T's .second

[edit] Return value

std::tuple of arguments suitable for passing to the constructor of T

[edit] Example

[edit] Notes

The overloads (2-6) provide allocator propagation into std::pair, which supports neither leading-allocator nor trailing-allocator calling conventions (unlike, e.g. std::tuple, which uses leading-allocator convention)

[edit] See also

checks if the specified type supports uses-allocator construction
(class template) [edit]
creates an object of the given type by means of uses-allocator construction
(function template) [edit]
creates an object of the given type at specified memory location by means of uses-allocator construction
(function template) [edit]