std::indirect<T, Allocator>::indirect
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Memory management library
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
Garbage collector support (until C++23)
(exposition only*)
(C++11)
(C++23)
(C++11)
(C++17)
(C++11)
(C++11)
(C++20)
(C++20)
(C++17)
(C++11)
(C++17)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(until C++20*)
(until C++20*)
(until C++20*)
(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)
(C++11)
(C++11)
(C++17)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
(until C++17*)
(C++11)
(C++17)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
std::indirect
indirect::indirect
constexpr explicit indirect();
(1)
(since C++26)
constexpr explicit indirect( std::allocator_arg_t, const Allocator& a );
(2)
(since C++26)
template< class U = T >
constexpr explicit indirect( U&& v );
(3)
(since C++26)
constexpr explicit indirect( U&& v );
template< class U = T >
(4)
(since C++26)
constexpr explicit indirect( std::allocator_arg_t, const Allocator& a,
template< class... Args >
constexpr explicit indirect( std::in_place_t, Args&&... args );
(5)
(since C++26)
constexpr explicit indirect( std::in_place_t, Args&&... args );
template< class... Args >
(6)
(since C++26)
constexpr explicit indirect( std::allocator_arg_t, const Allocator& a,
template< class I, class... Args >
(7)
(since C++26)
constexpr explicit indirect( std::in_place_t, std::initializer_list <I> ilist,
template< class I, class... Args >
(8)
(since C++26)
constexpr explicit indirect( std::allocator_arg_t, const Allocator& a,
std::in_place_t, std::initializer_list <I> ilist,
constexpr indirect( const indirect& other );
(9)
(since C++26)
constexpr indirect( std::allocator_arg_t, const Allocator& a,
const indirect& other );
(10)
(since C++26)
const indirect& other );
constexpr indirect( indirect&& other ) noexcept;
(11)
(since C++26)
constexpr indirect( std::allocator_arg_t, const Allocator& a,
indirect&& other ) noexcept(/* see below */);
(12)
(since C++26)
indirect&& other ) noexcept(/* see below */);
Constructs a new indirect
object.
Contents
[edit] Parameters
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
-
another
indirect
object whose owned value (if exists) is copied
[edit] Effects
The construction of a new indirect
object consists of the following steps:
1) Constructs the associated allocator
alloc
:
- If the initializer for
alloc
is empty, it is value-initialized. - If the initializer for
alloc
is not empty, it is direct-non-list-initialized with the initializer argument.
2) Constructs the owned object:
- For overloads (1-8), initialize
p
with the result of calling std::allocator_traits <Allocator>::allocate, then calls std::allocator_traits <Allocator>::construct(alloc
,p
, args...), where args... is an expression pack containing the initializer arguments. - For overloads (9-12):
- If other is valueless, no owned object is constructed, and *this is also valueless after construction.
- Otherwise, if other is an rvalue reference and
alloc
equals other.alloc
, *this takes ownership of the owned object of other. - Otherwise, the owned object is constructed using
alloc
as described above.
Overload | Initializer for... | valueless_after_move() after construction | |
---|---|---|---|
alloc
|
the owned object | ||
(1) | (empty) | (empty) | false |
(2) | a | ||
(3) | (empty) | std::forward <U>(v) | |
(4) | a | ||
(5) | (empty) | std::forward <Args>(args) | |
(6) | a | ||
(7) | (empty) | ilist, std::forward <Args>(args) | |
(8) | a | ||
(9) | see below | *other (only if other owns a value) |
true only if other is valueless |
(10) | a | ||
(11) | std::move(other.alloc )
|
takes ownership (only if other owns a value) | |
(12) | a | see below |
9)
alloc
is direct-non-list-initialized with std::allocator_traits <Allocator>::
select_on_container_copy_construction(other.alloc
).12) The owned object is constructed as follows:
[edit] Constraints and supplement information
1) This overload participates in overload resolution only if std::is_default_constructible_v <Allocator> is true.
3-8) These overloads participate in overload resolution only if std::is_constructible_v <T, /* argument types */> is true, where /* argument types */ are:
3,4)
U
5,6)
Args...
7,8) std::initializer_list <I>&, Args...
3,5,7) These overloads participate in overload resolution only if std::is_default_constructible_v <Allocator> is true.
3,4) These overloads participate in overload resolution only if the following values are all false:
- std::is_same_v <std::remove_cvref_t <U>, std::indirect>
- std::is_same_v <std::remove_cvref_t <U>, std::in_place_t >
11,12) When the construction completes, other is valueless.
12) If std::allocator_traits <Allocator>::is_always_equal::value is false and
T
is an incomplete type, the program is ill-formed.[edit] Exceptions
Throws nothing unless std::allocator_traits <Allocator>::allocate or std::allocator_traits <Allocator>::construct throws.
12)
noexcept specification:
noexcept(std::allocator_traits <Allocator>::is_always_equal::value)
[edit] Example
This section is incomplete
Reason: no example
Reason: no example