Files
2025-10-25 03:02:53 +03:00

765 B

[utility.exchange]

22 General utilities library [utilities]

22.2 Utility components [utility]

22.2.3 exchange [utility.exchange]

🔗

template<class T, class U = T> constexpr T exchange(T& obj, U&& new_val) noexcept(see below);

1

#

Effects: Equivalent to:T old_val = std::move(obj); obj = std::forward(new_val);return old_val;

2

#

Remarks: The exception specification is equivalent to:is_nothrow_move_constructible_v && is_nothrow_assignable_v<T&, U>