File indexing completed on 2025-01-18 09:41:27
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 fold_chunk<1>
0046 {
0047 template<
0048 typename First
0049 , typename Last
0050 , typename State
0051 , typename ForwardOp
0052 >
0053 struct result_
0054 {
0055 typedef First iter0;
0056 typedef State state0;
0057 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0058 typedef typename mpl::next<iter0>::type iter1;
0059
0060
0061 typedef state1 state;
0062 typedef iter1 iterator;
0063 };
0064 };
0065
0066 template<> struct fold_chunk<2>
0067 {
0068 template<
0069 typename First
0070 , typename Last
0071 , typename State
0072 , typename ForwardOp
0073 >
0074 struct result_
0075 {
0076 typedef First iter0;
0077 typedef State state0;
0078 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0079 typedef typename mpl::next<iter0>::type iter1;
0080 typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
0081 typedef typename mpl::next<iter1>::type iter2;
0082
0083
0084 typedef state2 state;
0085 typedef iter2 iterator;
0086 };
0087 };
0088
0089 template<> struct fold_chunk<3>
0090 {
0091 template<
0092 typename First
0093 , typename Last
0094 , typename State
0095 , typename ForwardOp
0096 >
0097 struct result_
0098 {
0099 typedef First iter0;
0100 typedef State state0;
0101 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0102 typedef typename mpl::next<iter0>::type iter1;
0103 typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
0104 typedef typename mpl::next<iter1>::type iter2;
0105 typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
0106 typedef typename mpl::next<iter2>::type iter3;
0107
0108
0109 typedef state3 state;
0110 typedef iter3 iterator;
0111 };
0112 };
0113
0114 template<> struct fold_chunk<4>
0115 {
0116 template<
0117 typename First
0118 , typename Last
0119 , typename State
0120 , typename ForwardOp
0121 >
0122 struct result_
0123 {
0124 typedef First iter0;
0125 typedef State state0;
0126 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0127 typedef typename mpl::next<iter0>::type iter1;
0128 typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
0129 typedef typename mpl::next<iter1>::type iter2;
0130 typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
0131 typedef typename mpl::next<iter2>::type iter3;
0132 typedef typename apply2< ForwardOp, state3, typename deref<iter3>::type >::type state4;
0133 typedef typename mpl::next<iter3>::type iter4;
0134
0135
0136 typedef state4 state;
0137 typedef iter4 iterator;
0138 };
0139 };
0140
0141 template< int N >
0142 struct fold_chunk
0143 {
0144 template<
0145 typename First
0146 , typename Last
0147 , typename State
0148 , typename ForwardOp
0149 >
0150 struct result_
0151 {
0152 typedef fold_impl<
0153 4
0154 , First
0155 , Last
0156 , State
0157 , ForwardOp
0158 > chunk_;
0159
0160 typedef fold_impl<
0161 ( (N - 4) < 0 ? 0 : N - 4 )
0162 , typename chunk_::iterator
0163 , Last
0164 , typename chunk_::state
0165 , ForwardOp
0166 > res_;
0167
0168 typedef typename res_::state state;
0169 typedef typename res_::iterator iterator;
0170 };
0171 };
0172
0173 template<
0174 typename First
0175 , typename Last
0176 , typename State
0177 , typename ForwardOp
0178 >
0179 struct fold_step;
0180
0181 template<
0182 typename Last
0183 , typename State
0184 >
0185 struct fold_null_step
0186 {
0187 typedef Last iterator;
0188 typedef State state;
0189 };
0190
0191 template<>
0192 struct fold_chunk< -1 >
0193 {
0194 template<
0195 typename First
0196 , typename Last
0197 , typename State
0198 , typename ForwardOp
0199 >
0200 struct result_
0201 {
0202 typedef typename if_<
0203 typename is_same< First,Last >::type
0204 , fold_null_step< Last,State >
0205 , fold_step< First,Last,State,ForwardOp >
0206 >::type 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 typedef fold_chunk< -1 >::template result_<
0222 typename mpl::next<First>::type
0223 , Last
0224 , typename apply2<ForwardOp,State, typename deref<First>::type>::type
0225 , ForwardOp
0226 > chunk_;
0227
0228 typedef typename chunk_::state state;
0229 typedef typename chunk_::iterator iterator;
0230 };
0231
0232 template<
0233 int N
0234 , typename First
0235 , typename Last
0236 , typename State
0237 , typename ForwardOp
0238 >
0239 struct fold_impl
0240 : fold_chunk<N>
0241 ::template result_< First,Last,State,ForwardOp >
0242 {
0243 };
0244
0245 }}}