std::experimental::any::operator=
来自 cppreference.cn
< cpp | experimental | any
any& operator=( const any& rhs ); |
(1) | (library fundamentals TS) |
any& operator=( any&& rhs ) noexcept; |
(2) | (library fundamentals TS) |
template< typename ValueType > any& operator=( ValueType&& rhs ); |
(3) | (library fundamentals 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 类型不同时,此重载才参与重载决议。
目录 |
[edit] 模板参数
ValueType | - | 包含值的类型 |
类型要求 | ||
-std::decay_t<ValueType> 必须满足 CopyConstructible 的要求。 |
[edit] 参数
rhs | - | 要赋值的包含值的对象 |
[edit] 返回值
*this
[edit] 异常
1,3) 抛出 bad_alloc 或包含类型构造函数抛出的任何异常。如果抛出异常,则不会有任何影响(强异常保证)。
[edit] 参见
构造一个 any 对象(公共成员函数) |