absl::exchange

Replace the value of an object and return its old value.

Synopsis

Declared in <absl/utility/utility.h>

template<
    class T1,
    class T2 = T1>
[[deprecated]]
constexpr
T1
exchange(
    T1& obj,
    T2&& new_value) noexcept(/* see-below */);

WARNING

Deprecated. Use of this entity is allowed but discouraged.

Exception specification

This function is potentially-throwing unless noexcept(std::exchange(std::declval<T1 &>(), std::declval<T2>())).

Return Value

The previous value of obj.

Parameters

NameDescription
objThe object whose value is replaced.
new_valueThe value to assign to obj.