blob: 05ce9b44b169b7451f734a316bc9a8cbd56ab3ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2006 Dan Marsden
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)
==============================================================================*/
#if !defined(BOOST_FUSION_SWAP_20070501_1956)
#define BOOST_FUSION_SWAP_20070501_1956
#include <boost/fusion/support/config.hpp>
#include <algorithm>
#include <boost/fusion/support/is_sequence.hpp>
#include <boost/fusion/view/zip_view.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/fusion/sequence/intrinsic/front.hpp>
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/mpl/and.hpp>
namespace boost { namespace fusion {
namespace result_of
{
template<typename Seq1, typename Seq2>
struct swap
{
typedef void type;
};
}
namespace detail
{
struct swap
{
template<typename Elem>
struct result
{
typedef void type;
};
template<typename Elem>
BOOST_FUSION_GPU_ENABLED
void operator()(Elem const& e) const
{
using std::swap;
swap(front(e), back(e));
}
};
}
template<typename Seq1, typename Seq2>
BOOST_FUSION_GPU_ENABLED
typename enable_if<mpl::and_<traits::is_sequence<Seq1>, traits::is_sequence<Seq2> >, void>::type
swap(Seq1& lhs, Seq2& rhs)
{
typedef vector<Seq1&, Seq2&> references;
for_each(zip_view<references>(references(lhs, rhs)), detail::swap());
}
}}
#endif
|