A constexpr exchange function. More...
Go to the source code of this file.
Functions | |
| template<class T, class U = T> | |
| constexpr T | ugmisc::xchg (T &object, U &&new_value) |
A constexpr exchange function.
In C++17 this provides an alternative to std::exchange which is constexpr. In C++20 this just forwards its arguments to std::exchange, which is constexpr anyway.
|
constexpr |
This is probably worse than std::exchange if you don't need it to be constexpr, but in the case that std::exchange is constexpr anyway, it just forwards the call to it.