1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2006 Dan Marsden
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_FUSION_SWAP_20070501_1956)
9 #define BOOST_FUSION_SWAP_20070501_1956
11 #include <boost/fusion/support/config.hpp>
14 #include <boost/fusion/support/is_sequence.hpp>
15 #include <boost/fusion/view/zip_view.hpp>
16 #include <boost/fusion/algorithm/iteration/for_each.hpp>
17 #include <boost/fusion/sequence/intrinsic/front.hpp>
18 #include <boost/fusion/sequence/intrinsic/back.hpp>
19 #include <boost/core/enable_if.hpp>
20 #include <boost/mpl/and.hpp>
22 namespace boost { namespace fusion {
26 template<typename Seq1, typename Seq2>
28 : enable_if<mpl::and_<
29 traits::is_sequence<Seq1>,
30 traits::is_sequence<Seq2>
38 template<typename Elem>
44 template<typename Elem>
45 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
46 void operator()(Elem const& e) const
49 swap(front(e), back(e));
54 template<typename Seq1, typename Seq2>
55 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
56 inline typename result_of::swap<Seq1, Seq2>::type
57 swap(Seq1& lhs, Seq2& rhs)
59 typedef vector<Seq1&, Seq2&> references;
60 for_each(zip_view<references>(references(lhs, rhs)), detail::swap());