std::experimental::any:: operator=
From cppreference.net
<
cpp
|
experimental
|
any
|
any
&
operator
=
(
const
any
&
rhs
)
;
|
(1) | (库基础技术规范) |
|
any
&
operator
=
(
any
&&
rhs
)
noexcept
;
|
(2) | (库基础技术规范) |
|
template
<
typename
ValueType
>
any & operator = ( ValueType && rhs ) ; |
(3) | (库基础技术规范) |
为所含值分配内容。
1)
通过复制
rhs
的状态进行赋值,如同执行
any
(
rhs
)
.
swap
(
*
this
)
。
2)
通过移动
rhs
的状态进行赋值,如同执行
any
(
std
::
move
(
rhs
)
)
.
swap
(
*
this
)
。赋值后
rhs
处于有效但未指定的状态。
3)
赋值
rhs
的类型和值,如同通过
any
(
std::
forward
<
ValueType
>
(
rhs
)
)
.
swap
(
*
this
)
进行。如果
std::
is_copy_constructible
<
std::
decay_t
<
ValueType
>>
::
value
为
false
,则程序非良构。此重载仅当
std::
decay_t
<
ValueType
>
与
any
不是同一类型时才参与重载决议。
目录 |
模板参数
| ValueType | - | 所含值的类型 |
| 类型要求 | ||
-
std::decay_t<ValueType>
必须满足
CopyConstructible
的要求。
|
||
参数
| rhs | - | 要赋值其包含值的对象 |
返回值
* this
异常
1,3)
抛出
bad_alloc
或所含类型构造函数抛出的任何异常。若抛出异常,则无任何副作用(强异常保证)。
另请参阅
构造
any
对象
(公开成员函数) |