Fix cx::swap to use move semantics

This commit is contained in:
rexy712 2020-05-07 11:54:56 -07:00
parent 981e57b34c
commit d876f65e7b

View File

@ -27,11 +27,12 @@ namespace rexy::cx{
namespace{ namespace{
template<class T> template<class T>
constexpr void swap(T& l, T& r) constexpr void swap(T& l, T& r)
noexcept(std::is_nothrow_copy_assignable<T>::value) noexcept(std::is_nothrow_move_assignable<T>::value &&
std::is_nothrow_move_constructible<T>::value)
{ {
T tmp = l; T tmp = std::move(l);
l = r; l = std::move(r);
r = tmp; r = std::move(tmp);
} }
template<class T, class U = T> template<class T, class U = T>
constexpr T exchange(T& l, U&& r) constexpr T exchange(T& l, U&& r)