std::experimental::any::operator=
来自 cppreference.cn
< cpp | experimental | any
any& operator=( const any& rhs ); |
(1) | (库基础 TS) |
any& operator=( any&& rhs ) noexcept; |
(2) | (库基础 TS) |
template< typename ValueType > any& operator=( ValueType&& rhs ); |
(3) | (库基础 TS) |
将内容赋给所包含的值。
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> 必须满足 可复制构造 的要求。 |
[编辑] 参数
rhs | - | 要赋值其所包含值的对象 |
[编辑] 返回值
*this
[编辑] 异常
1,3) 抛出 bad_alloc 或由所包含类型构造函数抛出的任何异常。如果抛出异常,则没有效果(强异常保证)。
[编辑] 参阅
构造一个 any 对象(public member function) |