|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
constexprexplicit polymorphic(); | (1) | (since C++26) |
constexprexplicit polymorphic(std::allocator_arg_t,const Allocator& a); | (2) | (since C++26) |
template<class U= T> constexprexplicit polymorphic( U&& v); | (3) | (since C++26) |
template<class U= T> constexprexplicit polymorphic(std::allocator_arg_t,const Allocator& a, | (4) | (since C++26) |
template<class U,class...Args> constexprexplicit polymorphic(std::in_place_type_t<U>, Args&&...args); | (5) | (since C++26) |
template<class U,class...Args> constexprexplicit polymorphic(std::allocator_arg_t,const Allocator& a, | (6) | (since C++26) |
template<class U,class I,class...Args> constexprexplicit polymorphic(std::in_place_type_t<U>, | (7) | (since C++26) |
template<class U,class I,class...Args> constexprexplicit polymorphic(std::allocator_arg_t,const Allocator& a, | (8) | (since C++26) |
constexpr polymorphic(const polymorphic& other); | (9) | (since C++26) |
constexpr polymorphic(std::allocator_arg_t,const Allocator& a, const polymorphic& other); | (10) | (since C++26) |
constexpr polymorphic( polymorphic&& other)noexcept; | (11) | (since C++26) |
constexpr polymorphic(std::allocator_arg_t,const Allocator& a, polymorphic&& other)noexcept(/* see below */); | (12) | (since C++26) |
Constructs a newpolymorphic object.
Contents |
| a | - | the allocator to be associated |
| v | - | value with which to initialize the owned value |
| args | - | arguments with which to initialize the owned value |
| il | - | initializer list with which to initialize the owned value |
| other | - | anotherpolymorphic object whose owned value (if exists) is copied |
The construction of a newpolymorphic object consists of the following steps:
alloc :alloc is empty, it isvalue-initialized.alloc is not empty, it isdirect-non-list-initialized with the initializer argument.alloc , p, args...), whereU*, it points to storage suitable for the owned object to be constructed, andalloc equalsother.alloc,*this takes ownership of the owned object ofother.alloc as described above, where the type ofp is determined by the type of the object owned byother.| Overload | Initializer for... | Type of the owned object | valueless_after_move()after construction | |
|---|---|---|---|---|
alloc | the owned object | |||
| (1) | (empty) | (empty) | T | false |
| (2) | a | |||
| (3) | (empty) | std::forward<U>(v) | U | |
| (4) | a | |||
| (5) | (empty) | std::forward<Args>(args) | ||
| (6) | a | |||
| (7) | (empty) | ilist, std::forward<Args>(args) | ||
| (8) | a | |||
| (9) | see below | *other (only ifother owns a value) | the type of the object owned byother | true only ifother is valueless |
| (10) | a | |||
| (11) | std::move (other.alloc ) | takes ownership (only ifother owns a value) | ||
| (12) | a | see below | ||
alloc is direct-non-list-initialized withstd::allocator_traits<Allocator>:: select_on_container_copy_construction(other.alloc ).UArgs...U is not a specialization ofstd::in_place_type_t.Throws nothing unlessstd::allocator_traits<Allocator>::allocate orstd::allocator_traits<Allocator>::construct throws.
| This section is incomplete Reason: no example |
(C++11) | tag type used to select allocator-aware constructor overloads (class)[edit] |
| in-place construction tag (tag)[edit] |