File indexing completed on 2025-01-18 09:41:12
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<
0027 typename First
0028 , typename Last
0029 , typename State
0030 , typename BackwardOp
0031 , typename ForwardOp
0032 >
0033 struct reverse_fold_impl< 0,First,Last,State,BackwardOp,ForwardOp >
0034 {
0035 typedef First iter0;
0036 typedef State fwd_state0;
0037 typedef fwd_state0 bkwd_state0;
0038 typedef bkwd_state0 state;
0039 typedef iter0 iterator;
0040 };
0041
0042 template<
0043 typename First
0044 , typename Last
0045 , typename State
0046 , typename BackwardOp
0047 , typename ForwardOp
0048 >
0049 struct reverse_fold_impl< 1,First,Last,State,BackwardOp,ForwardOp >
0050 {
0051 typedef First iter0;
0052 typedef State fwd_state0;
0053 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0054 typedef typename mpl::next<iter0>::type iter1;
0055
0056
0057 typedef fwd_state1 bkwd_state1;
0058 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0059 typedef bkwd_state0 state;
0060 typedef iter1 iterator;
0061 };
0062
0063 template<
0064 typename First
0065 , typename Last
0066 , typename State
0067 , typename BackwardOp
0068 , typename ForwardOp
0069 >
0070 struct reverse_fold_impl< 2,First,Last,State,BackwardOp,ForwardOp >
0071 {
0072 typedef First iter0;
0073 typedef State fwd_state0;
0074 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0075 typedef typename mpl::next<iter0>::type iter1;
0076 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0077 typedef typename mpl::next<iter1>::type iter2;
0078
0079
0080 typedef fwd_state2 bkwd_state2;
0081 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0082 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0083
0084
0085 typedef bkwd_state0 state;
0086 typedef iter2 iterator;
0087 };
0088
0089 template<
0090 typename First
0091 , typename Last
0092 , typename State
0093 , typename BackwardOp
0094 , typename ForwardOp
0095 >
0096 struct reverse_fold_impl< 3,First,Last,State,BackwardOp,ForwardOp >
0097 {
0098 typedef First iter0;
0099 typedef State fwd_state0;
0100 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0101 typedef typename mpl::next<iter0>::type iter1;
0102 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0103 typedef typename mpl::next<iter1>::type iter2;
0104 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0105 typedef typename mpl::next<iter2>::type iter3;
0106
0107
0108 typedef fwd_state3 bkwd_state3;
0109 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0110 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0111 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0112
0113
0114 typedef bkwd_state0 state;
0115 typedef iter3 iterator;
0116 };
0117
0118 template<
0119 typename First
0120 , typename Last
0121 , typename State
0122 , typename BackwardOp
0123 , typename ForwardOp
0124 >
0125 struct reverse_fold_impl< 4,First,Last,State,BackwardOp,ForwardOp >
0126 {
0127 typedef First iter0;
0128 typedef State fwd_state0;
0129 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0130 typedef typename mpl::next<iter0>::type iter1;
0131 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0132 typedef typename mpl::next<iter1>::type iter2;
0133 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0134 typedef typename mpl::next<iter2>::type iter3;
0135 typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
0136 typedef typename mpl::next<iter3>::type iter4;
0137
0138
0139 typedef fwd_state4 bkwd_state4;
0140 typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
0141 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0142 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0143 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0144
0145
0146 typedef bkwd_state0 state;
0147 typedef iter4 iterator;
0148 };
0149
0150 template<
0151 long N
0152 , typename First
0153 , typename Last
0154 , typename State
0155 , typename BackwardOp
0156 , typename ForwardOp
0157 >
0158 struct reverse_fold_impl
0159 {
0160 typedef First iter0;
0161 typedef State fwd_state0;
0162 typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
0163 typedef typename mpl::next<iter0>::type iter1;
0164 typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
0165 typedef typename mpl::next<iter1>::type iter2;
0166 typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
0167 typedef typename mpl::next<iter2>::type iter3;
0168 typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
0169 typedef typename mpl::next<iter3>::type iter4;
0170
0171
0172 typedef reverse_fold_impl<
0173 ( (N - 4) < 0 ? 0 : N - 4 )
0174 , iter4
0175 , Last
0176 , fwd_state4
0177 , BackwardOp
0178 , ForwardOp
0179 > nested_chunk;
0180
0181 typedef typename nested_chunk::state bkwd_state4;
0182 typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
0183 typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
0184 typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
0185 typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
0186
0187
0188 typedef bkwd_state0 state;
0189 typedef typename nested_chunk::iterator iterator;
0190 };
0191
0192 template<
0193 typename First
0194 , typename Last
0195 , typename State
0196 , typename BackwardOp
0197 , typename ForwardOp
0198 >
0199 struct reverse_fold_impl< -1,First,Last,State,BackwardOp,ForwardOp >
0200 {
0201 typedef reverse_fold_impl<
0202 -1
0203 , typename mpl::next<First>::type
0204 , Last
0205 , typename apply2<ForwardOp,State, typename deref<First>::type>::type
0206 , BackwardOp
0207 , ForwardOp
0208 > nested_step;
0209
0210 typedef typename apply2<
0211 BackwardOp
0212 , typename nested_step::state
0213 , typename deref<First>::type
0214 >::type state;
0215
0216 typedef typename nested_step::iterator iterator;
0217 };
0218
0219 template<
0220 typename Last
0221 , typename State
0222 , typename BackwardOp
0223 , typename ForwardOp
0224 >
0225 struct reverse_fold_impl< -1,Last,Last,State,BackwardOp,ForwardOp >
0226 {
0227 typedef State state;
0228 typedef Last iterator;
0229 };
0230
0231 }}}