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