Namespaces
Variants

std::indirect<T, Allocator>:: indirect

From cppreference.net
Memory management library
( exposition only* )
Allocators
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)
(Anmerkung: Der bereitgestellte HTML-Code enthält keinen übersetzbaren Text, da alle Tags und Attribute gemäß den Anweisungen unverändert bleiben sollen und die Tabellenzellen leer sind.)
constexpr explicit indirect ( ) ;
(1) (seit C++26)
constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a ) ;
(2) (seit C++26)
template < class U = T >
constexpr explicit indirect ( U && v ) ;
(3) (seit C++26)
template < class U = T >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,

U && v ) ;
(4) (seit C++26)
template < class ... Args >
constexpr explicit indirect ( std:: in_place_t , Args && ... args ) ;
(5) (seit C++26)
template < class ... Args >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,

std:: in_place_t , Args && ... args ) ;
(6) (seit C++26)
template < class I, class ... Args >

constexpr explicit indirect ( std:: in_place_t , std:: initializer_list < I > ilist,

Args && ... args ) ;
(7) (seit C++26)
template < class I, class ... Args >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,
std:: in_place_t , std:: initializer_list < I > ilist,

Args && ... args ) ;
(8) (seit C++26)
constexpr indirect ( const indirect & other ) ;
(9) (seit C++26)
constexpr indirect ( std:: allocator_arg_t , const Allocator & a,
const indirect & other ) ;
(10) (seit C++26)
constexpr indirect ( indirect && other ) noexcept ;
(11) (seit C++26)
constexpr indirect ( std:: allocator_arg_t , const Allocator & a,
indirect && other ) noexcept ( /* siehe unten */ ) ;
(12) (seit C++26)

Konstruiert ein neues indirect Objekt.

Inhaltsverzeichnis

Parameter

a - der Allokator, der zugeordnet werden soll
v - Wert, mit dem der enthaltene Wert initialisiert wird
args - Argumente, mit denen der enthaltene Wert initialisiert wird
il - Initialisierungsliste, mit der der enthaltene Wert initialisiert wird
other - ein anderes indirect -Objekt, dessen enthaltene Wert (falls vorhanden) kopiert wird

Effekte

Die Konstruktion eines neuen indirect Objekts besteht aus den folgenden Schritten:

1) Konstruiert den zugehörigen Allokator alloc :
2) Konstruiert das verwaltete Objekt:
  • Für Überladungen ( 1-8 ) , initialisiere p mit dem Ergebnis des Aufrufs von std:: allocator_traits < Allocator > :: allocate , dann rufe std:: allocator_traits < Allocator > :: construct ( alloc  , p  , args... ) , wobei args... ein Ausdruckspaket mit den Initialisierungsargumenten ist.
  • Für Überladungen ( 9-12 ) :
    • Wenn other wertlos ist, wird kein verwaltetes Objekt konstruiert, und * this ist nach der Konstruktion ebenfalls wertlos.
    • Andernfalls, wenn other ein Rvalue-Referenz ist und alloc gleich other. alloc ist, * this übernimmt das Eigentum am verwalteten Objekt von other .
    • Andernfalls wird das verwaltete Objekt unter Verwendung von alloc wie oben beschrieben konstruiert.
Überladung Initialisierer für... valueless_after_move()
nach Konstruktion
alloc das verwaltete Objekt
( 1 ) (leer) (leer) false
( 2 ) a
( 3 ) (leer) std:: forward < U > ( v )
( 4 ) a
( 5 ) (leer) std:: forward < Args > ( args )
( 6 ) a
( 7 ) (leer) ilist, std:: forward < Args > ( args )
( 8 ) a
( 9 ) siehe unten * other
(nur wenn other einen Wert besitzt)
true nur wenn other wertlos ist
( 10 ) a
( 11 ) std :: move ( other. alloc  ) übernimmt Besitz
(nur wenn other einen Wert besitzt)
( 12 ) a siehe unten
9) alloc wird direkt-nicht-Listen-initialisiert mit std:: allocator_traits < Allocator > ::
select_on_container_copy_construction ( other. alloc  )
.
12) Das besessene Objekt wird wie folgt konstruiert:
  • Wenn other wertlos ist, ist auch * this wertlos.
  • Andernfalls, wenn alloc == other. alloc true ist, übernimmt * this den Besitz des besessenen Objekts von other .
  • Andernfalls wird ein besessenes Objekt mit * std :: move ( other ) unter Verwendung von alloc konstruiert.

Einschränkungen und ergänzende Informationen

1,2) Falls std:: is_default_constructible_v < T > false ist, ist das Programm fehlerhaft.

1) Diese Überladung nimmt nur an der Überladungsauflösung teil, wenn std:: is_default_constructible_v < Allocator > true ist.

3-8) Diese Überladungen nehmen nur dann an der Überladungsauflösung teil, wenn std:: is_constructible_v < T, /* argument types */ > true ist, wobei /* argument types */ Folgendes sind:
3,4) U
5,6) Args...
7,8) std:: initializer_list < I > & , Args...

3,5,7) Diese Überladungen nehmen nur dann an der Überladungsauflösung teil, wenn std:: is_default_constructible_v < Allocator > true ist.
3,4) Diese Überladungen nehmen nur dann an der Überladungsauflösung teil, wenn alle der folgenden Werte false sind:

9,10) Wenn std:: is_copy_constructible_v < T > false ist, ist das Programm fehlerhaft.
11,12) Wenn der Konstruktionsvorgang abgeschlossen ist, other ist wertlos.
12) Wenn std:: allocator_traits < Allocator > :: is_always_equal :: value false ist und T ein unvollständiger Typ ist, ist das Programm fehlerhaft.

Exceptions

Wirft nichts, es sei denn std:: allocator_traits < Allocator > :: allocate oder std:: allocator_traits < Allocator > :: construct werfen.

12)
noexcept Spezifikation:
noexcept ( std:: allocator_traits < Allocator > :: is_always_equal :: value )

Beispiel

Siehe auch

Tag-Typ zur Auswahl von allocator-aware Konstruktorüberladungen
(Klasse)
In-place-Konstruktions-Tag
(Tag)