Fix cx::swap to use move semantics
This commit is contained in:
parent
981e57b34c
commit
d876f65e7b
@ -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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user