2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
|
|
|
Copyright (c) 2011-2013 Bolero MURAKAMI
|
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-10-05 15:58:56 +00:00
|
|
|
#ifndef SPROUT_UTILITY_SWAP_HPP
|
|
|
|
#define SPROUT_UTILITY_SWAP_HPP
|
|
|
|
|
2013-10-15 05:01:34 +00:00
|
|
|
#include <cstddef>
|
2012-10-05 15:58:56 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
|
|
|
|
namespace sprout_swap_detail {
|
|
|
|
using std::swap;
|
|
|
|
|
|
|
|
template<typename T>
|
2013-10-15 05:01:34 +00:00
|
|
|
inline SPROUT_CXX14_CONSTEXPR void
|
2012-10-05 15:58:56 +00:00
|
|
|
swap_impl(T& a, T& b)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(swap(a, b)))
|
|
|
|
{
|
2013-10-15 05:01:34 +00:00
|
|
|
swap(a, b);
|
|
|
|
}
|
|
|
|
template<typename T, std::size_t N>
|
|
|
|
inline SPROUT_CXX14_CONSTEXPR void
|
|
|
|
swap_impl(T (& a)[N], T (& b)[N])
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(swap(*a, *b)))
|
|
|
|
{
|
|
|
|
for (std::size_t i = 0; i < N; ++i) {
|
|
|
|
swap(a[i], b[i]);
|
|
|
|
}
|
2012-10-05 15:58:56 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout_swap_detail
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
2013-10-15 05:01:34 +00:00
|
|
|
// 20.2.2 swap
|
2012-10-05 15:58:56 +00:00
|
|
|
//
|
|
|
|
template<typename T1, typename T2>
|
2013-10-15 05:01:34 +00:00
|
|
|
inline SPROUT_CXX14_CONSTEXPR void
|
2012-10-05 15:58:56 +00:00
|
|
|
swap(T1& lhs, T2& rhs)
|
|
|
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_swap_detail::swap_impl(lhs, rhs)))
|
|
|
|
{
|
|
|
|
return sprout_swap_detail::swap_impl(lhs, rhs);
|
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_UTILITY_SWAP_HPP
|