std:: uses_allocator_construction_args
|
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,
|
(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,
|
(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,
|
(4) | (seit C++20) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(5) | (seit C++23) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(6) | (seit C++20) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(7) | (seit C++20) |
|
template
<
class
T,
class
Alloc,
class
U,
class
V
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(8) | (seit C++23) |
|
template
<
class
T,
class
Alloc,
class
NonPair
>
constexpr
auto
uses_allocator_construction_args
(
const
Alloc
&
alloc,
|
(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.
T
keine Spezialisierung von
std::pair
ist. Gibt
std::tuple
zurück, das wie folgt bestimmt wird:
- Wenn std:: uses_allocator_v < T, Alloc > false ist und std:: is_constructible_v < T, Args... > true ist, gibt std:: forward_as_tuple ( std:: forward < Args > ( args ) ... ) zurück.
-
Andernfalls, wenn
std::
uses_allocator_v
<
T, Alloc
>
true
ist und
std::
is_constructible_v
<
T,
std::
allocator_arg_t
,
const
Alloc
&
, Args...
>
true
ist, gibt
std:: tuple < std:: allocator_arg_t , const Alloc & , Args && ... > ( std:: allocator_arg , alloc,
std:: forward < Args > ( args ) ... ) zurück. - Andernfalls, wenn std:: uses_allocator_v < T, Alloc > true ist und std:: is_constructible_v < T, Args..., const Alloc & > true ist, gibt std:: forward_as_tuple ( std:: forward < Args > ( args ) ..., alloc ) zurück.
- Andernfalls ist das Programm fehlerhaft.
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) ) );
T
eine Spezialisierung von
std::pair
ist. Äquivalent zu
return std::uses_allocator_construction_args<T>(alloc, std::piecewise_construct, std::tuple<>{}, std::tuple<>{} );
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)) );
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) );
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))) );
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_)); } };
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
|
Dieser Abschnitt ist unvollständig
Grund: Kein 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
|
(C++11)
|
prüft, ob der angegebene Typ uses-allocator Konstruktion unterstützt
(Klassen-Template) |
|
(C++20)
|
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) |