File indexing completed on 2025-01-18 09:41:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 namespace boost { namespace mpl { namespace aux {
0013
0014
0015
0016 template<
0017 long N
0018 , typename First
0019 , typename Last
0020 , typename State
0021 , typename BackwardOp
0022 , typename ForwardOp
0023 >
0024 struct reverse_fold_impl;
0025
0026 template< long N >
0027 struct reverse_fold_chunk;
0028
0029 template<> struct reverse_fold_chunk<0>
0030 {
0031 template<
0032 typename First
0033 , typename Last
0034 , typename State
0035 , typename BackwardOp
0036 , typename ForwardOp
0037 >
0038 struct result_
0039 {
0040 typedef First iter0;
0041 typedef State fwd_state0;
0042 typedef fwd_state0 bkwd_state0;
0043 typedef bkwd_state0 state;
0044 typedef iter0 iterator;
0045 };
0046
0047
0048 template<> struct result_< int,int,int,int,int >
0049 {
0050 typedef int state;
0051 typedef int iterator;
0052 };
0053
0054 };
0055
0056 template<> struct reverse_fold_chunk<1>
0057 {
0058 template<
0059 typename First
0060 , typename Last
0061 , typename State
0062 , typename BackwardOp
0063 , typename ForwardOp
0064 >
0065 struct result_
0066 {
0067 typedef First iter0;
0068 typedef State fwd_state0;
0069 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0070 typedef typename mpl::next<iter0>::type iter1;
0071
0072
0073 typedef fwd_state1 bkwd_state1;
0074 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0075 typedef bkwd_state0 state;
0076 typedef iter1 iterator;
0077 };
0078
0079
0080 template<> struct result_< int,int,int,int,int >
0081 {
0082 typedef int state;
0083 typedef int iterator;
0084 };
0085
0086 };
0087
0088 template<> struct reverse_fold_chunk<2>
0089 {
0090 template<
0091 typename First
0092 , typename Last
0093 , typename State
0094 , typename BackwardOp
0095 , typename ForwardOp
0096 >
0097 struct result_
0098 {
0099 typedef First iter0;
0100 typedef State fwd_state0;
0101 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0102 typedef typename mpl::next<iter0>::type iter1;
0103 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0104 typedef typename mpl::next<iter1>::type iter2;
0105
0106
0107 typedef fwd_state2 bkwd_state2;
0108 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0109 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0110
0111
0112 typedef bkwd_state0 state;
0113 typedef iter2 iterator;
0114 };
0115
0116
0117 template<> struct result_< int,int,int,int,int >
0118 {
0119 typedef int state;
0120 typedef int iterator;
0121 };
0122
0123 };
0124
0125 template<> struct reverse_fold_chunk<3>
0126 {
0127 template<
0128 typename First
0129 , typename Last
0130 , typename State
0131 , typename BackwardOp
0132 , typename ForwardOp
0133 >
0134 struct result_
0135 {
0136 typedef First iter0;
0137 typedef State fwd_state0;
0138 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0139 typedef typename mpl::next<iter0>::type iter1;
0140 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0141 typedef typename mpl::next<iter1>::type iter2;
0142 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0143 typedef typename mpl::next<iter2>::type iter3;
0144
0145
0146 typedef fwd_state3 bkwd_state3;
0147 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0148 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0149 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0150
0151
0152 typedef bkwd_state0 state;
0153 typedef iter3 iterator;
0154 };
0155
0156
0157 template<> struct result_< int,int,int,int,int >
0158 {
0159 typedef int state;
0160 typedef int iterator;
0161 };
0162
0163 };
0164
0165 template<> struct reverse_fold_chunk<4>
0166 {
0167 template<
0168 typename First
0169 , typename Last
0170 , typename State
0171 , typename BackwardOp
0172 , typename ForwardOp
0173 >
0174 struct result_
0175 {
0176 typedef First iter0;
0177 typedef State fwd_state0;
0178 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0179 typedef typename mpl::next<iter0>::type iter1;
0180 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0181 typedef typename mpl::next<iter1>::type iter2;
0182 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0183 typedef typename mpl::next<iter2>::type iter3;
0184 typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
0185 typedef typename mpl::next<iter3>::type iter4;
0186
0187
0188 typedef fwd_state4 bkwd_state4;
0189 typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
0190 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0191 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0192 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0193
0194
0195 typedef bkwd_state0 state;
0196 typedef iter4 iterator;
0197 };
0198
0199
0200 template<> struct result_< int,int,int,int,int >
0201 {
0202 typedef int state;
0203 typedef int iterator;
0204 };
0205
0206 };
0207
0208 template< long N >
0209 struct reverse_fold_chunk
0210 {
0211 template<
0212 typename First
0213 , typename Last
0214 , typename State
0215 , typename BackwardOp
0216 , typename ForwardOp
0217 >
0218 struct result_
0219 {
0220 typedef First iter0;
0221 typedef State fwd_state0;
0222 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0223 typedef typename mpl::next<iter0>::type iter1;
0224 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0225 typedef typename mpl::next<iter1>::type iter2;
0226 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0227 typedef typename mpl::next<iter2>::type iter3;
0228 typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
0229 typedef typename mpl::next<iter3>::type iter4;
0230
0231
0232 typedef reverse_fold_impl<
0233 ( (N - 4) < 0 ? 0 : N - 4 )
0234 , iter4
0235 , Last
0236 , fwd_state4
0237 , BackwardOp
0238 , ForwardOp
0239 > nested_chunk;
0240
0241 typedef typename nested_chunk::state bkwd_state4;
0242 typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
0243 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0244 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0245 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0246
0247
0248 typedef bkwd_state0 state;
0249 typedef typename nested_chunk::iterator iterator;
0250 };
0251 };
0252
0253 template<
0254 typename First
0255 , typename Last
0256 , typename State
0257 , typename BackwardOp
0258 , typename ForwardOp
0259 >
0260 struct reverse_fold_step;
0261
0262 template<
0263 typename Last
0264 , typename State
0265 >
0266 struct reverse_fold_null_step
0267 {
0268 typedef Last iterator;
0269 typedef State state;
0270 };
0271
0272 template<>
0273 struct reverse_fold_chunk< -1 >
0274 {
0275 template<
0276 typename First
0277 , typename Last
0278 , typename State
0279 , typename BackwardOp
0280 , typename ForwardOp
0281 >
0282 struct result_
0283 {
0284 typedef typename if_<
0285 typename is_same< First,Last >::type
0286 , reverse_fold_null_step< Last,State >
0287 , reverse_fold_step< First,Last,State,BackwardOp,ForwardOp >
0288 >::type res_;
0289
0290 typedef typename res_::state state;
0291 typedef typename res_::iterator iterator;
0292 };
0293
0294
0295 template<> struct result_< int,int,int,int,int >
0296 {
0297 typedef int state;
0298 typedef int iterator;
0299 };
0300
0301 };
0302
0303 template<
0304 typename First
0305 , typename Last
0306 , typename State
0307 , typename BackwardOp
0308 , typename ForwardOp
0309 >
0310 struct reverse_fold_step
0311 {
0312 typedef reverse_fold_chunk< -1 >::template result_<
0313 typename mpl::next<First>::type
0314 , Last
0315 , typename apply2<ForwardOp,State, typename deref<First>::type>::type
0316 , BackwardOp
0317 , ForwardOp
0318 > nested_step;
0319
0320 typedef typename apply2<
0321 BackwardOp
0322 , typename nested_step::state
0323 , typename deref<First>::type
0324 >::type state;
0325
0326 typedef typename nested_step::iterator iterator;
0327 };
0328
0329 template<
0330 long N
0331 , typename First
0332 , typename Last
0333 , typename State
0334 , typename BackwardOp
0335 , typename ForwardOp
0336 >
0337 struct reverse_fold_impl
0338 : reverse_fold_chunk<N>
0339 ::template result_< First,Last,State,BackwardOp,ForwardOp >
0340 {
0341 };
0342
0343 }}}