std::polymorphic<T, Allocator>:: polymorphic
|
constexpr
explicit
polymorphic
(
)
;
|
(1) | (seit C++26) |
|
constexpr
explicit
polymorphic
(
std::
allocator_arg_t
,
const
Allocator
&
a
)
;
|
(2) | (seit C++26) |
|
template
<
class
U
=
T
>
constexpr explicit polymorphic ( U && v ) ; |
(3) | (seit C++26) |
|
template
<
class
U
=
T
>
constexpr
explicit
polymorphic
(
std::
allocator_arg_t
,
const
Allocator
&
a,
|
(4) | (seit C++26) |
|
template
<
class
U,
class
...
Args
>
constexpr explicit polymorphic ( std:: in_place_type_t < U > , Args && ... args ) ; |
(5) | (seit C++26) |
|
template
<
class
U,
class
...
Args
>
constexpr
explicit
polymorphic
(
std::
allocator_arg_t
,
const
Allocator
&
a,
|
(6) | (seit C++26) |
|
template
<
class
U,
class
I,
class
...
Args
>
constexpr
explicit
polymorphic
(
std::
in_place_type_t
<
U
>
,
|
(7) | (seit C++26) |
|
template
<
class
U,
class
I,
class
...
Args
>
constexpr
explicit
polymorphic
(
std::
allocator_arg_t
,
const
Allocator
&
a,
|
(8) | (seit C++26) |
|
constexpr
polymorphic
(
const
polymorphic
&
other
)
;
|
(9) | (seit C++26) |
|
constexpr
polymorphic
(
std::
allocator_arg_t
,
const
Allocator
&
a,
const polymorphic & other ) ; |
(10) | (seit C++26) |
|
constexpr
polymorphic
(
polymorphic
&&
other
)
noexcept
;
|
(11) | (seit C++26) |
|
constexpr
polymorphic
(
std::
allocator_arg_t
,
const
Allocator
&
a,
polymorphic && other ) noexcept ( /* siehe unten */ ) ; |
(12) | (seit C++26) |
Konstruiert ein neues
polymorphic
Objekt.
Inhaltsverzeichnis |
Parameter
| a | - | der zuzuordnende Allokator |
| v | - | Wert zur Initialisierung des enthaltenen Werts |
| args | - | Argumente zur Initialisierung des enthaltenen Werts |
| il | - | Initialisierungsliste zur Initialisierung des enthaltenen Werts |
| other | - |
ein weiteres
polymorphic
Objekt, dessen enthaltener Wert (falls vorhanden) kopiert wird
|
Auswirkungen
Die Erstellung eines neuen
polymorphic
Objekts besteht aus den folgenden Schritten:
alloc
:
-
Wenn der Initialisierer für
allocleer ist, wird er wertinitialisiert . -
Wenn der Initialisierer für
allocnicht leer ist, wird er direkt-nicht-Listen-initialisiert mit dem Initialisiererargument.
-
Für Überladungen
(
1-8
)
, ruft
std::
allocator_traits
<
Allocator
>
::
construct
(
alloc ,p, args... ) , wobei-
p
ein Zeiger vom Typ
U*ist, der auf Speicherplatz für das zu konstruierende verwaltete Objekt zeigt, und - args... ein Ausdruckspaket mit den Initialisierungsargumenten ist.
-
p
ein Zeiger vom Typ
-
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
eine Rvalue-Referenz ist und
allocgleich other.allocist, * this übernimmt das Eigentum am verwalteten Objekt von other . -
Andernfalls wird das verwaltete Objekt unter Verwendung von
allocwie oben beschrieben konstruiert, wobei der Typ von p durch den Typ des von other verwalteten Objekts bestimmt wird.
| Überladung | Initialisierer für... | Typ des besessenen Objekts |
valueless_after_move()
nach Konstruktion |
|
|---|---|---|---|---|
alloc
|
das besessene Objekt | |||
| ( 1 ) | (leer) | (leer) |
T
|
false |
| ( 2 ) | a | |||
| ( 3 ) | (leer) | std:: forward < U > ( v ) |
U
|
|
| ( 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) |
der Typ des von other besessenen Objekts | 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 | ||
alloc
wird direkt-nicht-Listen-initialisiert mit
std::
allocator_traits
<
Allocator
>
::
select_on_container_copy_construction
(
other.
alloc
)
.
Einschränkungen und ergänzende Informationen
- std:: derived_from < std:: remove_cvref_t < U > , T >
- std:: is_copy_constructible_v < std:: remove_cvref_t < U >>
- std:: is_constructible_v < std:: remove_cvref_t < U > , /* argument types */ > , wobei /* argument types */ sind:
U
Args...
- std:: is_same_v < std:: remove_cvref_t < U > , std :: polymorphic > ist false .
-
Uist keine Spezialisierung von std::in_place_type_t .
Exceptions
Wirft nichts, es sei denn std:: allocator_traits < Allocator > :: allocate oder std:: allocator_traits < Allocator > :: construct werfen.
Beispiel
|
Dieser Abschnitt ist unvollständig
Grund: Kein Beispiel |
Siehe auch
|
(C++11)
|
Markierungstyp zur Auswahl von Allokator-konstruktorüberladungen
(Klasse) |
|
In-place-Konstruktionsmarkierung
(Markierung) |