std::experimental::ranges::exchange
From cppreference.com
< cpp | experimental | ranges
Defined in header <experimental/ranges/utility>
|
||
template< MoveConstructible T, class U = T > requires Assignable<T&, U> |
(ranges TS) | |
Replaces the value of obj with new_value and returns the old value of obj, as if by
T old_value = std::move(obj); obj = std::forward<U>(new_value); return old_value;
Contents |
[edit] Parameters
obj | - | object whose value to replace |
new_value | - | the value to assign to obj
|
[edit] Return value
The old value of obj.
[edit] Exceptions
noexcept specification:
noexcept(std::is_nothrow_move_constructible<T>::value &&
std::is_nothrow_assignable<T&, U>::value)
std::is_nothrow_assignable<T&, U>::value)
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
(C++14) |
replaces the argument with a new value and returns its previous value (function template) |