diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 5a714fee2f..0d95585aa0 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -81,14 +81,6 @@ inline T&& move(T& arg) # pragma clang diagnostic pop #endif -template -inline T exchange(T& a, U&& b) -{ - T tmp = move(a); - a = move(b); - return tmp; -} - template inline void swap(T& a, U& b) { @@ -370,6 +362,14 @@ struct MakeUnsigned { typedef unsigned long long type; }; +template +inline constexpr T exchange(T& slot, U&& value) +{ + T old_value = move(slot); + slot = forward(value); + return old_value; +} + } using AK::ceil_div;