Chris@16
|
1
|
Chris@16
|
2 #ifndef BOOST_MPL_TRANSFORM_HPP_INCLUDED
|
Chris@16
|
3 #define BOOST_MPL_TRANSFORM_HPP_INCLUDED
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright Aleksey Gurtovoy 2000-2004
|
Chris@16
|
6 // Copyright David Abrahams 2003-2004
|
Chris@16
|
7 //
|
Chris@16
|
8 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
9 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
10 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
11 //
|
Chris@16
|
12 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
13
|
Chris@101
|
14 // $Id$
|
Chris@101
|
15 // $Date$
|
Chris@101
|
16 // $Revision$
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/mpl/fold.hpp>
|
Chris@16
|
19 #include <boost/mpl/reverse_fold.hpp>
|
Chris@16
|
20 #include <boost/mpl/pair_view.hpp>
|
Chris@16
|
21 #include <boost/mpl/is_sequence.hpp>
|
Chris@16
|
22 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
23 #include <boost/mpl/lambda.hpp>
|
Chris@16
|
24 #include <boost/mpl/bind.hpp>
|
Chris@16
|
25 #include <boost/mpl/or.hpp>
|
Chris@16
|
26 #include <boost/mpl/not.hpp>
|
Chris@16
|
27 #include <boost/mpl/aux_/na.hpp>
|
Chris@16
|
28 #include <boost/mpl/aux_/inserter_algorithm.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost { namespace mpl {
|
Chris@16
|
31
|
Chris@16
|
32 namespace aux {
|
Chris@16
|
33
|
Chris@16
|
34 template<
|
Chris@16
|
35 typename Seq
|
Chris@16
|
36 , typename Op
|
Chris@16
|
37 , typename In
|
Chris@16
|
38 >
|
Chris@16
|
39 struct transform1_impl
|
Chris@16
|
40 : fold<
|
Chris@16
|
41 Seq
|
Chris@16
|
42 , typename In::state
|
Chris@16
|
43 , bind2< typename lambda< typename In::operation >::type
|
Chris@16
|
44 , _1
|
Chris@16
|
45 , bind1< typename lambda<Op>::type, _2>
|
Chris@16
|
46 >
|
Chris@16
|
47 >
|
Chris@16
|
48 {
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 template<
|
Chris@16
|
52 typename Seq
|
Chris@16
|
53 , typename Op
|
Chris@16
|
54 , typename In
|
Chris@16
|
55 >
|
Chris@16
|
56 struct reverse_transform1_impl
|
Chris@16
|
57 : reverse_fold<
|
Chris@16
|
58 Seq
|
Chris@16
|
59 , typename In::state
|
Chris@16
|
60 , bind2< typename lambda< typename In::operation >::type
|
Chris@16
|
61 , _1
|
Chris@16
|
62 , bind1< typename lambda<Op>::type, _2>
|
Chris@16
|
63 >
|
Chris@16
|
64 >
|
Chris@16
|
65 {
|
Chris@16
|
66 };
|
Chris@16
|
67
|
Chris@16
|
68 template<
|
Chris@16
|
69 typename Seq1
|
Chris@16
|
70 , typename Seq2
|
Chris@16
|
71 , typename Op
|
Chris@16
|
72 , typename In
|
Chris@16
|
73 >
|
Chris@16
|
74 struct transform2_impl
|
Chris@16
|
75 : fold<
|
Chris@16
|
76 pair_view<Seq1,Seq2>
|
Chris@16
|
77 , typename In::state
|
Chris@16
|
78 , bind2< typename lambda< typename In::operation >::type
|
Chris@16
|
79 , _1
|
Chris@16
|
80 , bind2<
|
Chris@16
|
81 typename lambda<Op>::type
|
Chris@16
|
82 , bind1<first<>,_2>
|
Chris@16
|
83 , bind1<second<>,_2>
|
Chris@16
|
84 >
|
Chris@16
|
85 >
|
Chris@16
|
86 >
|
Chris@16
|
87 {
|
Chris@16
|
88 };
|
Chris@16
|
89
|
Chris@16
|
90 template<
|
Chris@16
|
91 typename Seq1
|
Chris@16
|
92 , typename Seq2
|
Chris@16
|
93 , typename Op
|
Chris@16
|
94 , typename In
|
Chris@16
|
95 >
|
Chris@16
|
96 struct reverse_transform2_impl
|
Chris@16
|
97 : reverse_fold<
|
Chris@16
|
98 pair_view<Seq1,Seq2>
|
Chris@16
|
99 , typename In::state
|
Chris@16
|
100 , bind2< typename lambda< typename In::operation >::type
|
Chris@16
|
101 , _1
|
Chris@16
|
102 , bind2< typename lambda< Op >::type
|
Chris@16
|
103 , bind1<first<>,_2>
|
Chris@16
|
104 , bind1<second<>,_2>
|
Chris@16
|
105 >
|
Chris@16
|
106 >
|
Chris@16
|
107 >
|
Chris@16
|
108 {
|
Chris@16
|
109 };
|
Chris@16
|
110
|
Chris@16
|
111 } // namespace aux
|
Chris@16
|
112
|
Chris@16
|
113 BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(3, transform1)
|
Chris@16
|
114 BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(4, transform2)
|
Chris@16
|
115
|
Chris@16
|
116 #define AUX778076_TRANSFORM_DEF(name) \
|
Chris@16
|
117 template< \
|
Chris@16
|
118 typename BOOST_MPL_AUX_NA_PARAM(Seq1) \
|
Chris@16
|
119 , typename BOOST_MPL_AUX_NA_PARAM(Seq2OrOperation) \
|
Chris@16
|
120 , typename BOOST_MPL_AUX_NA_PARAM(OperationOrInserter) \
|
Chris@16
|
121 , typename BOOST_MPL_AUX_NA_PARAM(Inserter) \
|
Chris@16
|
122 > \
|
Chris@16
|
123 struct name \
|
Chris@16
|
124 { \
|
Chris@16
|
125 typedef typename eval_if< \
|
Chris@16
|
126 or_< \
|
Chris@16
|
127 is_na<OperationOrInserter> \
|
Chris@16
|
128 , is_lambda_expression< Seq2OrOperation > \
|
Chris@16
|
129 , not_< is_sequence<Seq2OrOperation> > \
|
Chris@16
|
130 > \
|
Chris@16
|
131 , name##1<Seq1,Seq2OrOperation,OperationOrInserter> \
|
Chris@16
|
132 , name##2<Seq1,Seq2OrOperation,OperationOrInserter,Inserter> \
|
Chris@16
|
133 >::type type; \
|
Chris@16
|
134 }; \
|
Chris@16
|
135 BOOST_MPL_AUX_NA_SPEC(4, name) \
|
Chris@16
|
136 /**/
|
Chris@16
|
137
|
Chris@16
|
138 AUX778076_TRANSFORM_DEF(transform)
|
Chris@16
|
139 AUX778076_TRANSFORM_DEF(reverse_transform)
|
Chris@16
|
140
|
Chris@16
|
141 #undef AUX778076_TRANSFORM_DEF
|
Chris@16
|
142
|
Chris@16
|
143 }}
|
Chris@16
|
144
|
Chris@16
|
145 #endif // BOOST_MPL_TRANSFORM_HPP_INCLUDED
|