File indexing completed on 2025-01-18 09:34:42
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_FUSION_SWAP_20070501_1956)
0009 #define BOOST_FUSION_SWAP_20070501_1956
0010
0011 #include <boost/fusion/support/config.hpp>
0012 #include <algorithm>
0013
0014 #include <boost/fusion/support/is_sequence.hpp>
0015 #include <boost/fusion/view/zip_view.hpp>
0016 #include <boost/fusion/algorithm/iteration/for_each.hpp>
0017 #include <boost/fusion/sequence/intrinsic/front.hpp>
0018 #include <boost/fusion/sequence/intrinsic/back.hpp>
0019 #include <boost/core/enable_if.hpp>
0020 #include <boost/mpl/and.hpp>
0021
0022 namespace boost { namespace fusion {
0023
0024 namespace result_of
0025 {
0026 template<typename Seq1, typename Seq2>
0027 struct swap
0028 : enable_if<mpl::and_<
0029 traits::is_sequence<Seq1>,
0030 traits::is_sequence<Seq2>
0031 > > {};
0032 }
0033
0034 namespace detail
0035 {
0036 struct swap
0037 {
0038 template<typename Elem>
0039 struct result
0040 {
0041 typedef void type;
0042 };
0043
0044 template<typename Elem>
0045 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0046 void operator()(Elem const& e) const
0047 {
0048 using std::swap;
0049 swap(front(e), back(e));
0050 }
0051 };
0052 }
0053
0054 template<typename Seq1, typename Seq2>
0055 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0056 inline typename result_of::swap<Seq1, Seq2>::type
0057 swap(Seq1& lhs, Seq2& rhs)
0058 {
0059 typedef vector<Seq1&, Seq2&> references;
0060 for_each(zip_view<references>(references(lhs, rhs)), detail::swap());
0061 }
0062 }}
0063
0064 #endif