File indexing completed on 2025-01-18 09:41:31
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<
0026 typename First
0027 , typename Last
0028 , typename State
0029 , typename ForwardOp
0030 >
0031 struct fold_impl< 0,First,Last,State,ForwardOp >
0032 {
0033 typedef First iter0;
0034 typedef State state0;
0035 typedef state0 state;
0036 typedef iter0 iterator;
0037 };
0038
0039 template<
0040 typename First
0041 , typename Last
0042 , typename State
0043 , typename ForwardOp
0044 >
0045 struct fold_impl< 1,First,Last,State,ForwardOp >
0046 {
0047 typedef First iter0;
0048 typedef State state0;
0049 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0050 typedef typename mpl::next<iter0>::type iter1;
0051
0052
0053 typedef state1 state;
0054 typedef iter1 iterator;
0055 };
0056
0057 template<
0058 typename First
0059 , typename Last
0060 , typename State
0061 , typename ForwardOp
0062 >
0063 struct fold_impl< 2,First,Last,State,ForwardOp >
0064 {
0065 typedef First iter0;
0066 typedef State state0;
0067 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0068 typedef typename mpl::next<iter0>::type iter1;
0069 typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
0070 typedef typename mpl::next<iter1>::type iter2;
0071
0072
0073 typedef state2 state;
0074 typedef iter2 iterator;
0075 };
0076
0077 template<
0078 typename First
0079 , typename Last
0080 , typename State
0081 , typename ForwardOp
0082 >
0083 struct fold_impl< 3,First,Last,State,ForwardOp >
0084 {
0085 typedef First iter0;
0086 typedef State state0;
0087 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0088 typedef typename mpl::next<iter0>::type iter1;
0089 typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
0090 typedef typename mpl::next<iter1>::type iter2;
0091 typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
0092 typedef typename mpl::next<iter2>::type iter3;
0093
0094
0095 typedef state3 state;
0096 typedef iter3 iterator;
0097 };
0098
0099 template<
0100 typename First
0101 , typename Last
0102 , typename State
0103 , typename ForwardOp
0104 >
0105 struct fold_impl< 4,First,Last,State,ForwardOp >
0106 {
0107 typedef First iter0;
0108 typedef State state0;
0109 typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
0110 typedef typename mpl::next<iter0>::type iter1;
0111 typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
0112 typedef typename mpl::next<iter1>::type iter2;
0113 typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
0114 typedef typename mpl::next<iter2>::type iter3;
0115 typedef typename apply2< ForwardOp, state3, typename deref<iter3>::type >::type state4;
0116 typedef typename mpl::next<iter3>::type iter4;
0117
0118
0119 typedef state4 state;
0120 typedef iter4 iterator;
0121 };
0122
0123 template<
0124 int N
0125 , typename First
0126 , typename Last
0127 , typename State
0128 , typename ForwardOp
0129 >
0130 struct fold_impl
0131 {
0132 typedef fold_impl<
0133 4
0134 , First
0135 , Last
0136 , State
0137 , ForwardOp
0138 > chunk_;
0139
0140 typedef fold_impl<
0141 ( (N - 4) < 0 ? 0 : N - 4 )
0142 , typename chunk_::iterator
0143 , Last
0144 , typename chunk_::state
0145 , ForwardOp
0146 > res_;
0147
0148 typedef typename res_::state state;
0149 typedef typename res_::iterator iterator;
0150 };
0151
0152 template<
0153 typename First
0154 , typename Last
0155 , typename State
0156 , typename ForwardOp
0157 >
0158 struct fold_impl< -1,First,Last,State,ForwardOp >
0159 : fold_impl<
0160 -1
0161 , typename mpl::next<First>::type
0162 , Last
0163 , typename apply2<ForwardOp,State, typename deref<First>::type>::type
0164 , ForwardOp
0165 >
0166 {
0167 };
0168
0169 template<
0170 typename Last
0171 , typename State
0172 , typename ForwardOp
0173 >
0174 struct fold_impl< -1,Last,Last,State,ForwardOp >
0175 {
0176 typedef State state;
0177 typedef Last iterator;
0178 };
0179
0180 }}}