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