exchange
namespace opentl {
template <typename T, typename U = T>
constexpr T exchange(T& obj, U&& new_value) noexcept;
}
Replaces an object with a new value and returns its old value.
Template Parameters
| Name | Description |
|---|---|
T |
The type of obj. |
U |
The type of new_value. |
Parameters
| Name | Description |
|---|---|
obj |
The object to replace. |
new_value |
The new value assigned to obj. |
Return Value
Returns the old value of obj before replacement.