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)
Definiert in Header <memory>
T ist keine Spezialisierung von std::pair
template < class T, class Alloc, class ... Args >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

Args && ... args ) noexcept ;
(1) (seit C++20)
T ist eine Spezialisierung von 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) (seit C++20)
template < class T, class Alloc >
constexpr auto uses_allocator_construction_args ( const Alloc & alloc ) noexcept ;
(3) (seit 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) (seit 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) (seit 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) (seit 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) (seit 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) (seit C++23)
template < class T, class Alloc, class NonPair >

constexpr auto uses_allocator_construction_args ( const Alloc & alloc,

NonPair && non_pair ) noexcept ;
(9) (seit C++20)

Bereitet die Argumentliste vor, die benötigt wird, um ein Objekt des gegebenen Typs T mittels Uses-Allocator-Konstruktion zu erstellen.

1) Diese Überladung nimmt nur an der Überladungsauflösung teil, wenn T keine Spezialisierung von std::pair ist. Gibt std::tuple zurück, das wie folgt bestimmt wird:
2) Diese Überladung nimmt nur an der Überladungsauflösung teil, wenn T eine Spezialisierung von std::pair ist. Für T als std:: pair < T1, T2 > , äquivalent zu
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) Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn T eine Spezialisierung von std::pair ist. Äquivalent zu
return std::uses_allocator_construction_args<T>(alloc,
    std::piecewise_construct, std::tuple<>{}, std::tuple<>{}
);
4) Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn T eine Spezialisierung von std::pair ist. Entspricht
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) Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn T eine Spezialisierung von std::pair ist. Entspricht
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) Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn T eine Spezialisierung von std::pair ist. Entspricht
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) Diese Überladung nimmt nur dann an der Überladungsauflösung teil, wenn T eine Spezialisierung von std::pair ist, und unter Berücksichtigung der nur zur Darstellung dienenden Funktionsvorlage
template<class A, class B>
void /*deduce-as-pair*/(const std::pair<A, B>&);

, /*deduce-as-pair*/ ( non_pair ) ist fehlerhaft, wenn sie als nicht ausgewerteter Operand betrachtet wird.
Sei die nur zur Darstellung dienende Klasse pair-constructor definiert als

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_));
    }
};
Diese Überladung ist äquivalent zu return std:: make_tuple ( pair_construction ) ; , wobei pair_construction ein Wert vom Typ pair-constructor ist, dessen alloc_ - und u_ -Member alloc bzw. non_pair sind.

Inhaltsverzeichnis

Parameter

alloc - der zu verwendende Allokator
args - die Argumente, die an den Konstruktor von T übergeben werden
x - Tupel von Argumenten, die an die Konstruktoren des first -Datenelements von T übergeben werden
y - Tupel von Argumenten, die an die Konstruktoren des second -Datenelements von T übergeben werden
u - einzelnes Argument, das an den Konstruktor des first -Datenelements von T übergeben wird
v - einzelnes Argument, das an den Konstruktor des second -Datenelements von T übergeben wird
pr - ein Paar, dessen first -Datenelement an den Konstruktor des first -Datenelements von T und dessen second -Datenelement an den Konstruktor des second -Datenelements von T übergeben wird
non_pair - einzelnes Argument, das in ein std::pair konvertiert wird für die weitere Konstruktion

Rückgabewert

std::tuple von Argumenten, die zum Übergeben an den Konstruktor von T geeignet sind.

Hinweise

Die Überladungen (2-9) ermöglichen die Allokatorweitergabe in std::pair , welches weder Leading-Allocator noch Trailing-Allocator Aufrufkonventionen unterstützt (im Gegensatz zu z.B. std::tuple , welches die Leading-Allocator Konvention verwendet).

Bei Verwendung in der Uses-Allocator-Konstruktion konvertiert die Konvertierungsfunktion von pair-constructor das bereitgestellte Argument zunächst zu std::pair und konstruiert dann das Ergebnis aus diesem std::pair durch Uses-Allocator-Konstruktion.

Beispiel

Fehlerberichte

Die folgenden verhaltensändernden Fehlerberichte wurden rückwirkend auf zuvor veröffentlichte C++-Standards angewendet.

DR Angewendet auf Verhalten wie veröffentlicht Korrigiertes Verhalten
LWG 3525 C++20 keine Überladung konnte Nicht- pair -Typen, die in pair konvertierbar sind, verarbeiten rekonstruierende Überladung hinzugefügt

Siehe auch

prüft, ob der angegebene Typ uses-allocator Konstruktion unterstützt
(Klassen-Template)
erstellt ein Objekt des gegebenen Typs mittels uses-allocator Konstruktion
(Funktions-Template)
erstellt ein Objekt des gegebenen Typs an einem spezifizierten Speicherort mittels uses-allocator Konstruktion
(Funktions-Template)