]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/mpl/transform.hpp
Logo AND Algorithmique Numérique Distribuée

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