std::experimental::any::operator=
來自 cppreference.com
< 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) |