File indexing completed on 2025-01-18 09:41:22
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 reverse_fold_chunk<1>
0049 {
0050 template<
0051 typename First
0052 , typename Last
0053 , typename State
0054 , typename BackwardOp
0055 , typename ForwardOp
0056 >
0057 struct result_
0058 {
0059 typedef First iter0;
0060 typedef State fwd_state0;
0061 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0062 typedef typename mpl::next<iter0>::type iter1;
0063
0064
0065 typedef fwd_state1 bkwd_state1;
0066 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0067 typedef bkwd_state0 state;
0068 typedef iter1 iterator;
0069 };
0070 };
0071
0072 template<> struct reverse_fold_chunk<2>
0073 {
0074 template<
0075 typename First
0076 , typename Last
0077 , typename State
0078 , typename BackwardOp
0079 , typename ForwardOp
0080 >
0081 struct result_
0082 {
0083 typedef First iter0;
0084 typedef State fwd_state0;
0085 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0086 typedef typename mpl::next<iter0>::type iter1;
0087 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0088 typedef typename mpl::next<iter1>::type iter2;
0089
0090
0091 typedef fwd_state2 bkwd_state2;
0092 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0093 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0094
0095
0096 typedef bkwd_state0 state;
0097 typedef iter2 iterator;
0098 };
0099 };
0100
0101 template<> struct reverse_fold_chunk<3>
0102 {
0103 template<
0104 typename First
0105 , typename Last
0106 , typename State
0107 , typename BackwardOp
0108 , typename ForwardOp
0109 >
0110 struct result_
0111 {
0112 typedef First iter0;
0113 typedef State fwd_state0;
0114 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0115 typedef typename mpl::next<iter0>::type iter1;
0116 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0117 typedef typename mpl::next<iter1>::type iter2;
0118 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0119 typedef typename mpl::next<iter2>::type iter3;
0120
0121
0122 typedef fwd_state3 bkwd_state3;
0123 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0124 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0125 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0126
0127
0128 typedef bkwd_state0 state;
0129 typedef iter3 iterator;
0130 };
0131 };
0132
0133 template<> struct reverse_fold_chunk<4>
0134 {
0135 template<
0136 typename First
0137 , typename Last
0138 , typename State
0139 , typename BackwardOp
0140 , typename ForwardOp
0141 >
0142 struct result_
0143 {
0144 typedef First iter0;
0145 typedef State fwd_state0;
0146 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0147 typedef typename mpl::next<iter0>::type iter1;
0148 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0149 typedef typename mpl::next<iter1>::type iter2;
0150 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0151 typedef typename mpl::next<iter2>::type iter3;
0152 typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
0153 typedef typename mpl::next<iter3>::type iter4;
0154
0155
0156 typedef fwd_state4 bkwd_state4;
0157 typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
0158 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0159 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0160 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0161
0162
0163 typedef bkwd_state0 state;
0164 typedef iter4 iterator;
0165 };
0166 };
0167
0168 template< long N >
0169 struct reverse_fold_chunk
0170 {
0171 template<
0172 typename First
0173 , typename Last
0174 , typename State
0175 , typename BackwardOp
0176 , typename ForwardOp
0177 >
0178 struct result_
0179 {
0180 typedef First iter0;
0181 typedef State fwd_state0;
0182 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0183 typedef typename mpl::next<iter0>::type iter1;
0184 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0185 typedef typename mpl::next<iter1>::type iter2;
0186 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0187 typedef typename mpl::next<iter2>::type iter3;
0188 typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
0189 typedef typename mpl::next<iter3>::type iter4;
0190
0191
0192 typedef reverse_fold_impl<
0193 ( (N - 4) < 0 ? 0 : N - 4 )
0194 , iter4
0195 , Last
0196 , fwd_state4
0197 , BackwardOp
0198 , ForwardOp
0199 > nested_chunk;
0200
0201 typedef typename nested_chunk::state bkwd_state4;
0202 typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
0203 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0204 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0205 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0206
0207
0208 typedef bkwd_state0 state;
0209 typedef typename nested_chunk::iterator iterator;
0210 };
0211 };
0212
0213 template<
0214 typename First
0215 , typename Last
0216 , typename State
0217 , typename BackwardOp
0218 , typename ForwardOp
0219 >
0220 struct reverse_fold_step;
0221
0222 template<
0223 typename Last
0224 , typename State
0225 >
0226 struct reverse_fold_null_step
0227 {
0228 typedef Last iterator;
0229 typedef State state;
0230 };
0231
0232 template<>
0233 struct reverse_fold_chunk< -1 >
0234 {
0235 template<
0236 typename First
0237 , typename Last
0238 , typename State
0239 , typename BackwardOp
0240 , typename ForwardOp
0241 >
0242 struct result_
0243 {
0244 typedef typename if_<
0245 typename is_same< First,Last >::type
0246 , reverse_fold_null_step< Last,State >
0247 , reverse_fold_step< First,Last,State,BackwardOp,ForwardOp >
0248 >::type res_;
0249
0250 typedef typename res_::state state;
0251 typedef typename res_::iterator iterator;
0252 };
0253 };
0254
0255 template<
0256 typename First
0257 , typename Last
0258 , typename State
0259 , typename BackwardOp
0260 , typename ForwardOp
0261 >
0262 struct reverse_fold_step
0263 {
0264 typedef reverse_fold_chunk< -1 >::template result_<
0265 typename mpl::next<First>::type
0266 , Last
0267 , typename apply2<ForwardOp,State, typename deref<First>::type>::type
0268 , BackwardOp
0269 , ForwardOp
0270 > nested_step;
0271
0272 typedef typename apply2<
0273 BackwardOp
0274 , typename nested_step::state
0275 , typename deref<First>::type
0276 >::type state;
0277
0278 typedef typename nested_step::iterator iterator;
0279 };
0280
0281 template<
0282 long N
0283 , typename First
0284 , typename Last
0285 , typename State
0286 , typename BackwardOp
0287 , typename ForwardOp
0288 >
0289 struct reverse_fold_impl
0290 : reverse_fold_chunk<N>
0291 ::template result_< First,Last,State,BackwardOp,ForwardOp >
0292 {
0293 };
0294
0295 }}}