std::experimental::ranges::exchange
來自 cppreference.com
< cpp | experimental | ranges
定義於標頭檔案 <experimental/ranges/utility> |
||
template< MoveConstructible T, class U = T > requires Assignable<T&, U> |
(ranges TS) | |
替換 obj 的值並返回 obj 的舊值,如同透過
T old_value = std::move(obj); obj = std::forward<U>(new_value); return old_value;
目錄 |
[編輯] 引數
obj | - | 要替換其值的物件 |
new_value | - | 要賦值給 obj 的值 |
[編輯] 返回值
obj 的舊值。
[編輯] 異常
noexcept 規範:
noexcept(std::is_nothrow_move_constructible<T>::value &&
std::is_nothrow_assignable<T&, U>::value)
std::is_nothrow_assignable<T&, U>::value)
[編輯] 示例
本節不完整 原因:無示例 |
[編輯] 參閱
(C++14) |
用新值替換引數並返回其舊值 (函式模板) |