diff --git a/sprout/utility/swap.hpp b/sprout/utility/swap.hpp index 718f84e1..a11c3981 100644 --- a/sprout/utility/swap.hpp +++ b/sprout/utility/swap.hpp @@ -10,12 +10,22 @@ #include #include +#include #include +#include +#include namespace sprout_swap_detail { using std::swap; - template + template::value>::type = sprout::enabler> + inline SPROUT_CXX14_CONSTEXPR void + swap_impl(T& a, T& b) SPROUT_NOEXCEPT { + T temp = sprout::move(a); + a = sprout::move(b); + b = sprout::move(temp); + } + template::value>::type = sprout::enabler> inline SPROUT_CXX14_CONSTEXPR void swap_impl(T& a, T& b) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(swap(a, b))) @@ -25,10 +35,10 @@ namespace sprout_swap_detail { template inline SPROUT_CXX14_CONSTEXPR void swap_impl(T (& a)[N], T (& b)[N]) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(swap(*a, *b))) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_swap_detail::swap_impl(*a, *b))) { for (std::size_t i = 0; i < N; ++i) { - swap(a[i], b[i]); + sprout_swap_detail::swap_impl(a[i], b[i]); } } } // namespace sprout_swap_detail