Replace the value of an object and return its old value.
Declared in <absl/utility/utility.h>
template<
class T1,
class T2 = T1>
[[deprecated]]
constexpr
T1
exchange(
T1& obj,
T2&& new_value) noexcept(/* see-below */);
Deprecated. Use of this entity is allowed but discouraged.
This function is potentially-throwing unless noexcept(std::exchange(std::declval<T1 &>(), std::declval<T2>())).
The previous value of obj.
| Name | Description |
|---|---|
| obj | The object whose value is replaced. |
| new_value | The value to assign to obj. |