iter_fold_impl.hpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. // Copyright Aleksey Gurtovoy 2000-2004
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Preprocessed version of "boost/mpl/aux_/iter_fold_impl.hpp" header
  8. // -- DO NOT modify by hand!
  9. namespace boost { namespace mpl { namespace aux {
  10. /// forward declaration
  11. template<
  12. int N
  13. , typename First
  14. , typename Last
  15. , typename State
  16. , typename ForwardOp
  17. >
  18. struct iter_fold_impl;
  19. template< int N >
  20. struct iter_fold_chunk;
  21. template<> struct iter_fold_chunk<0>
  22. {
  23. template<
  24. typename First
  25. , typename Last
  26. , typename State
  27. , typename ForwardOp
  28. >
  29. struct result_
  30. {
  31. typedef First iter0;
  32. typedef State state0;
  33. typedef state0 state;
  34. typedef iter0 iterator;
  35. };
  36. };
  37. template<> struct iter_fold_chunk<1>
  38. {
  39. template<
  40. typename First
  41. , typename Last
  42. , typename State
  43. , typename ForwardOp
  44. >
  45. struct result_
  46. {
  47. typedef First iter0;
  48. typedef State state0;
  49. typedef typename apply2< ForwardOp,state0,iter0 >::type state1;
  50. typedef typename mpl::next<iter0>::type iter1;
  51. typedef state1 state;
  52. typedef iter1 iterator;
  53. };
  54. };
  55. template<> struct iter_fold_chunk<2>
  56. {
  57. template<
  58. typename First
  59. , typename Last
  60. , typename State
  61. , typename ForwardOp
  62. >
  63. struct result_
  64. {
  65. typedef First iter0;
  66. typedef State state0;
  67. typedef typename apply2< ForwardOp,state0,iter0 >::type state1;
  68. typedef typename mpl::next<iter0>::type iter1;
  69. typedef typename apply2< ForwardOp,state1,iter1 >::type state2;
  70. typedef typename mpl::next<iter1>::type iter2;
  71. typedef state2 state;
  72. typedef iter2 iterator;
  73. };
  74. };
  75. template<> struct iter_fold_chunk<3>
  76. {
  77. template<
  78. typename First
  79. , typename Last
  80. , typename State
  81. , typename ForwardOp
  82. >
  83. struct result_
  84. {
  85. typedef First iter0;
  86. typedef State state0;
  87. typedef typename apply2< ForwardOp,state0,iter0 >::type state1;
  88. typedef typename mpl::next<iter0>::type iter1;
  89. typedef typename apply2< ForwardOp,state1,iter1 >::type state2;
  90. typedef typename mpl::next<iter1>::type iter2;
  91. typedef typename apply2< ForwardOp,state2,iter2 >::type state3;
  92. typedef typename mpl::next<iter2>::type iter3;
  93. typedef state3 state;
  94. typedef iter3 iterator;
  95. };
  96. };
  97. template<> struct iter_fold_chunk<4>
  98. {
  99. template<
  100. typename First
  101. , typename Last
  102. , typename State
  103. , typename ForwardOp
  104. >
  105. struct result_
  106. {
  107. typedef First iter0;
  108. typedef State state0;
  109. typedef typename apply2< ForwardOp,state0,iter0 >::type state1;
  110. typedef typename mpl::next<iter0>::type iter1;
  111. typedef typename apply2< ForwardOp,state1,iter1 >::type state2;
  112. typedef typename mpl::next<iter1>::type iter2;
  113. typedef typename apply2< ForwardOp,state2,iter2 >::type state3;
  114. typedef typename mpl::next<iter2>::type iter3;
  115. typedef typename apply2< ForwardOp,state3,iter3 >::type state4;
  116. typedef typename mpl::next<iter3>::type iter4;
  117. typedef state4 state;
  118. typedef iter4 iterator;
  119. };
  120. };
  121. template< int N >
  122. struct iter_fold_chunk
  123. {
  124. template<
  125. typename First
  126. , typename Last
  127. , typename State
  128. , typename ForwardOp
  129. >
  130. struct result_
  131. {
  132. typedef iter_fold_impl<
  133. 4
  134. , First
  135. , Last
  136. , State
  137. , ForwardOp
  138. > chunk_;
  139. typedef iter_fold_impl<
  140. ( (N - 4) < 0 ? 0 : N - 4 )
  141. , typename chunk_::iterator
  142. , Last
  143. , typename chunk_::state
  144. , ForwardOp
  145. > res_;
  146. typedef typename res_::state state;
  147. typedef typename res_::iterator iterator;
  148. };
  149. };
  150. template<
  151. typename First
  152. , typename Last
  153. , typename State
  154. , typename ForwardOp
  155. >
  156. struct iter_fold_step;
  157. template<
  158. typename Last
  159. , typename State
  160. >
  161. struct iter_fold_null_step
  162. {
  163. typedef Last iterator;
  164. typedef State state;
  165. };
  166. template<>
  167. struct iter_fold_chunk< -1 >
  168. {
  169. template<
  170. typename First
  171. , typename Last
  172. , typename State
  173. , typename ForwardOp
  174. >
  175. struct result_
  176. {
  177. typedef typename if_<
  178. typename is_same< First,Last >::type
  179. , iter_fold_null_step< Last,State >
  180. , iter_fold_step< First,Last,State,ForwardOp >
  181. >::type res_;
  182. typedef typename res_::state state;
  183. typedef typename res_::iterator iterator;
  184. };
  185. };
  186. template<
  187. typename First
  188. , typename Last
  189. , typename State
  190. , typename ForwardOp
  191. >
  192. struct iter_fold_step
  193. {
  194. typedef iter_fold_chunk< -1 >::template result_<
  195. typename mpl::next<First>::type
  196. , Last
  197. , typename apply2< ForwardOp,State,First >::type
  198. , ForwardOp
  199. > chunk_;
  200. typedef typename chunk_::state state;
  201. typedef typename chunk_::iterator iterator;
  202. };
  203. template<
  204. int N
  205. , typename First
  206. , typename Last
  207. , typename State
  208. , typename ForwardOp
  209. >
  210. struct iter_fold_impl
  211. : iter_fold_chunk<N>
  212. ::template result_< First,Last,State,ForwardOp >
  213. {
  214. };
  215. }}}