std::indirect<T, Allocator>:: indirect
|
constexpr
explicit
indirect
(
)
;
|
(1) | (自 C++26 起) |
|
constexpr
explicit
indirect
(
std::
allocator_arg_t
,
const
Allocator
&
a
)
;
|
(2) | (自 C++26 起) |
|
template
<
class
U
=
T
>
constexpr explicit indirect ( U && v ) ; |
(3) | (自 C++26 起) |
|
template
<
class
U
=
T
>
constexpr
explicit
indirect
(
std::
allocator_arg_t
,
const
Allocator
&
a,
|
(4) | (自 C++26 起) |
|
template
<
class
...
Args
>
constexpr explicit indirect ( std:: in_place_t , Args && ... args ) ; |
(5) | (自 C++26 起) |
|
template
<
class
...
Args
>
constexpr
explicit
indirect
(
std::
allocator_arg_t
,
const
Allocator
&
a,
|
(6) | (自 C++26 起) |
|
template
<
class
I,
class
...
Args
>
constexpr
explicit
indirect
(
std::
in_place_t
,
std::
initializer_list
<
I
>
ilist,
|
(7) | (自 C++26 起) |
|
template
<
class
I,
class
...
Args
>
constexpr
explicit
indirect
(
std::
allocator_arg_t
,
const
Allocator
&
a,
|
(8) | (自 C++26 起) |
|
constexpr
indirect
(
const
indirect
&
other
)
;
|
(9) | (自 C++26 起) |
|
constexpr
indirect
(
std::
allocator_arg_t
,
const
Allocator
&
a,
const indirect & other ) ; |
(10) | (自 C++26 起) |
|
constexpr
indirect
(
indirect
&&
other
)
noexcept
;
|
(11) | (自 C++26 起) |
|
constexpr
indirect
(
std::
allocator_arg_t
,
const
Allocator
&
a,
indirect && other ) noexcept ( /* 见下文 */ ) ; |
(12) | (自 C++26 起) |
构造一个新的
indirect
对象。
目录 |
参数
| a | - | 要关联的分配器 |
| v | - | 用于初始化所拥有值的初始值 |
| args | - | 用于初始化所拥有值的参数 |
| il | - | 用于初始化所拥有值的初始化列表 |
| other | - |
另一个
indirect
对象,其拥有的值(若存在)将被复制
|
效果
新
indirect
对象的构造包含以下步骤:
-
对于重载
(
1-8
)
,使用调用
std::
allocator_traits
<
Allocator
>
::
allocate
的结果初始化
p,随后调用 std:: allocator_traits < Allocator > :: construct (alloc ,p , args... ) ,其中 args... 是包含初始化参数的表达式包。 - 对于重载 ( 9-12 ) :
| 重载版本 | 初始化器用于... |
valueless_after_move()
构造后状态 |
|
|---|---|---|---|
alloc
|
被管理对象 | ||
| ( 1 ) | (空) | (空) | false |
| ( 2 ) | a | ||
| ( 3 ) | (空) | std:: forward < U > ( v ) | |
| ( 4 ) | a | ||
| ( 5 ) | (空) | std:: forward < Args > ( args ) | |
| ( 6 ) | a | ||
| ( 7 ) | (空) | ilist, std:: forward < Args > ( args ) | |
| ( 8 ) | a | ||
| ( 9 ) | 见下文 |
*
other
(仅当 other 持有值时) |
true 仅当 other 为无值状态 |
| ( 10 ) | a | ||
| ( 11 ) |
std
::
move
(
other.
alloc
)
|
取得所有权
(仅当 other 持有值时) |
|
| ( 12 ) | a | 见下文 | |
alloc
通过
std::
allocator_traits
<
Allocator
>
::
select_on_container_copy_construction
(
other.
alloc
)
进行直接非列表初始化。
约束条件与补充信息
U
Args...
- std:: is_same_v < std:: remove_cvref_t < U > , std :: indirect >
- std:: is_same_v < std:: remove_cvref_t < U > , std:: in_place_t >
T
是
不完整类型
,则程序非良构。
异常
除非 std:: allocator_traits < Allocator > :: allocate 或 std:: allocator_traits < Allocator > :: construct 抛出异常,否则不会抛出任何异常。
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
(C++11)
|
用于选择分配器感知构造函数重载的标签类型
(类) |
|
原位构造标签
(标签) |