Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/fusion/sequence/intrinsic/swap.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2001-2011 Joel de Guzman | |
3 Copyright (c) 2006 Dan Marsden | |
4 | |
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 | |
10 | |
11 #include <algorithm> | |
12 | |
13 #include <boost/fusion/support/is_sequence.hpp> | |
14 #include <boost/fusion/view/zip_view.hpp> | |
15 #include <boost/fusion/algorithm/iteration/for_each.hpp> | |
16 #include <boost/utility/enable_if.hpp> | |
17 #include <boost/fusion/sequence/intrinsic/front.hpp> | |
18 #include <boost/fusion/sequence/intrinsic/back.hpp> | |
19 #include <boost/mpl/and.hpp> | |
20 | |
21 namespace boost { namespace fusion { | |
22 namespace result_of | |
23 { | |
24 template<typename Seq1, typename Seq2> | |
25 struct swap | |
26 { | |
27 typedef void type; | |
28 }; | |
29 } | |
30 | |
31 namespace detail | |
32 { | |
33 struct swap | |
34 { | |
35 template<typename Elem> | |
36 struct result | |
37 { | |
38 typedef void type; | |
39 }; | |
40 | |
41 template<typename Elem> | |
42 void operator()(Elem const& e) const | |
43 { | |
44 using std::swap; | |
45 swap(front(e), back(e)); | |
46 } | |
47 }; | |
48 } | |
49 | |
50 template<typename Seq1, typename Seq2> | |
51 typename enable_if<mpl::and_<traits::is_sequence<Seq1>, traits::is_sequence<Seq2> >, void>::type | |
52 swap(Seq1& lhs, Seq2& rhs) | |
53 { | |
54 typedef vector<Seq1&, Seq2&> references; | |
55 for_each(zip_view<references>(references(lhs, rhs)), detail::swap()); | |
56 } | |
57 }} | |
58 | |
59 #endif |