std::experimental::unique_resource<R, D>::operator=
來自 cppreference.com
< cpp | experimental | unique_resource
unique_resource& operator=( unique_resource&& other ) noexcept(/*見下文*/); |
(庫基礎 TS v3) | |
移動賦值運算子。用 other 的資源和刪除器替換當前管理的資源和刪除器。
形式上,設 RS
為儲存資源控制代碼的型別
- 首先,呼叫 reset() 來處置當前擁有的資源(如果有)。
- 然後,用 other 的儲存資源控制代碼和刪除器賦值。如果 std::is_nothrow_move_assignable_v<RS> 或 std::is_nothrow_move_assignable_v<D> 分別為 true,則將
std::move
應用於 other 的儲存資源控制代碼或刪除器。儲存資源控制代碼的賦值先執行,除非 std::is_nothrow_move_assignable_v<D> 為 false 且 std::is_nothrow_move_assignable_v<RS> 為 true。 - 最後,當且僅當 other 在賦值前擁有資源時,設定 *this 擁有資源,且 other 不再擁有資源。
如果 std::is_nothrow_move_assignable_v<RS> 為 true,則 RS
應滿足 可移動賦值 (MoveAssignable) 的要求;否則 RS
應滿足 可複製賦值 (CopyAssignable) 的要求。如果 std::is_nothrow_move_assignable_v<D> 為 true,則 D
應滿足 可移動賦值 (MoveAssignable) 的要求;否則 D
應滿足 可複製賦值 (CopyAssignable) 的要求。未能滿足上述要求將導致未定義行為。
目錄 |
[編輯] 引數
其他 | - | 資源包裝器,所有權將從其轉移 |
[編輯] 返回值
*this
[編輯] 異常
複製賦值中丟擲的任何異常。
noexcept 規範:
noexcept(std::is_nothrow_move_assignable_v<RS> && std::is_nothrow_move_assignable_v<D>)
[編輯] 註解
如果成員的複製丟擲異常,此機制會使 other 保持不變,並將 *this 置於已釋放狀態。
[編輯] 示例
本節不完整 原因:無示例 |
[編輯] 參閱
處置或替換所管理的資源 (public member function) | |
賦值 unique_ptr ( std::unique_ptr<T,Deleter> 的公共成員函式) |