123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #ifndef BOOST_CORE_INVOKE_SWAP_HPP
- #define BOOST_CORE_INVOKE_SWAP_HPP
- #include <boost/core/enable_if.hpp>
- #include <boost/config.hpp>
- #if __cplusplus >= 201103L || defined(BOOST_DINKUMWARE_STDLIB)
- #include <utility> // for std::swap (C++11)
- #else
- #include <algorithm> // for std::swap (C++98)
- #endif
- #include <cstddef> // for std::size_t
- #ifdef BOOST_HAS_PRAGMA_ONCE
- #pragma once
- #endif
- #if defined(BOOST_GCC) && (BOOST_GCC < 40700)
- #define BOOST_CORE_SWAP_NOEXCEPT_IF(x)
- #else
- #define BOOST_CORE_SWAP_NOEXCEPT_IF(x) BOOST_NOEXCEPT_IF(x)
- #endif
- namespace boost_swap_impl {
- template<class T> struct is_const { enum _vt { value = 0 }; };
- template<class T> struct is_const<T const> { enum _vt { value = 1 }; };
- using namespace std;
- template<class T>
- BOOST_GPU_ENABLED
- inline void invoke_swap_impl(T& left, T& right) BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(swap(left, right)))
- {
- swap(left, right);
- }
- template<class T, std::size_t N>
- BOOST_GPU_ENABLED
- inline void invoke_swap_impl(T (& left)[N], T (& right)[N])
- BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::invoke_swap_impl(left[0], right[0])))
- {
- for (std::size_t i = 0; i < N; ++i)
- {
- ::boost_swap_impl::invoke_swap_impl(left[i], right[i]);
- }
- }
- } // namespace boost_swap_impl
- namespace boost {
- namespace core {
- template<class T>
- BOOST_GPU_ENABLED
- inline typename enable_if_c< !::boost_swap_impl::is_const<T>::value >::type
- invoke_swap(T& left, T& right)
- BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::invoke_swap_impl(left, right)))
- {
- ::boost_swap_impl::invoke_swap_impl(left, right);
- }
- }
- }
- #undef BOOST_CORE_SWAP_NOEXCEPT_IF
- #endif
|