From d876f65e7b1a38057413f3eefd5e3a661a2767b0 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Thu, 7 May 2020 11:54:56 -0700 Subject: [PATCH] Fix cx::swap to use move semantics --- include/rexy/cx/utility.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/rexy/cx/utility.hpp b/include/rexy/cx/utility.hpp index 4074450..8deb581 100644 --- a/include/rexy/cx/utility.hpp +++ b/include/rexy/cx/utility.hpp @@ -27,11 +27,12 @@ namespace rexy::cx{ namespace{ template constexpr void swap(T& l, T& r) - noexcept(std::is_nothrow_copy_assignable::value) + noexcept(std::is_nothrow_move_assignable::value && + std::is_nothrow_move_constructible::value) { - T tmp = l; - l = r; - r = tmp; + T tmp = std::move(l); + l = std::move(r); + r = std::move(tmp); } template constexpr T exchange(T& l, U&& r)