reverse_fold_impl.hpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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_/reverse_fold_impl.hpp" header
  8. // -- DO NOT modify by hand!
  9. namespace boost { namespace mpl { namespace aux {
  10. /// forward declaration
  11. template<
  12. long N
  13. , typename First
  14. , typename Last
  15. , typename State
  16. , typename BackwardOp
  17. , typename ForwardOp
  18. >
  19. struct reverse_fold_impl;
  20. template<
  21. typename First
  22. , typename Last
  23. , typename State
  24. , typename BackwardOp
  25. , typename ForwardOp
  26. >
  27. struct reverse_fold_impl< 0,First,Last,State,BackwardOp,ForwardOp >
  28. {
  29. typedef First iter0;
  30. typedef State fwd_state0;
  31. typedef fwd_state0 bkwd_state0;
  32. typedef bkwd_state0 state;
  33. typedef iter0 iterator;
  34. };
  35. template<
  36. typename First
  37. , typename Last
  38. , typename State
  39. , typename BackwardOp
  40. , typename ForwardOp
  41. >
  42. struct reverse_fold_impl< 1,First,Last,State,BackwardOp,ForwardOp >
  43. {
  44. typedef First iter0;
  45. typedef State fwd_state0;
  46. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  47. typedef typename mpl::next<iter0>::type iter1;
  48. typedef fwd_state1 bkwd_state1;
  49. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  50. typedef bkwd_state0 state;
  51. typedef iter1 iterator;
  52. };
  53. template<
  54. typename First
  55. , typename Last
  56. , typename State
  57. , typename BackwardOp
  58. , typename ForwardOp
  59. >
  60. struct reverse_fold_impl< 2,First,Last,State,BackwardOp,ForwardOp >
  61. {
  62. typedef First iter0;
  63. typedef State fwd_state0;
  64. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  65. typedef typename mpl::next<iter0>::type iter1;
  66. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  67. typedef typename mpl::next<iter1>::type iter2;
  68. typedef fwd_state2 bkwd_state2;
  69. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  70. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  71. typedef bkwd_state0 state;
  72. typedef iter2 iterator;
  73. };
  74. template<
  75. typename First
  76. , typename Last
  77. , typename State
  78. , typename BackwardOp
  79. , typename ForwardOp
  80. >
  81. struct reverse_fold_impl< 3,First,Last,State,BackwardOp,ForwardOp >
  82. {
  83. typedef First iter0;
  84. typedef State fwd_state0;
  85. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  86. typedef typename mpl::next<iter0>::type iter1;
  87. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  88. typedef typename mpl::next<iter1>::type iter2;
  89. typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
  90. typedef typename mpl::next<iter2>::type iter3;
  91. typedef fwd_state3 bkwd_state3;
  92. typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
  93. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  94. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  95. typedef bkwd_state0 state;
  96. typedef iter3 iterator;
  97. };
  98. template<
  99. typename First
  100. , typename Last
  101. , typename State
  102. , typename BackwardOp
  103. , typename ForwardOp
  104. >
  105. struct reverse_fold_impl< 4,First,Last,State,BackwardOp,ForwardOp >
  106. {
  107. typedef First iter0;
  108. typedef State fwd_state0;
  109. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  110. typedef typename mpl::next<iter0>::type iter1;
  111. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  112. typedef typename mpl::next<iter1>::type iter2;
  113. typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
  114. typedef typename mpl::next<iter2>::type iter3;
  115. typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
  116. typedef typename mpl::next<iter3>::type iter4;
  117. typedef fwd_state4 bkwd_state4;
  118. typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
  119. typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
  120. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  121. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  122. typedef bkwd_state0 state;
  123. typedef iter4 iterator;
  124. };
  125. template<
  126. long N
  127. , typename First
  128. , typename Last
  129. , typename State
  130. , typename BackwardOp
  131. , typename ForwardOp
  132. >
  133. struct reverse_fold_impl
  134. {
  135. typedef First iter0;
  136. typedef State fwd_state0;
  137. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  138. typedef typename mpl::next<iter0>::type iter1;
  139. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  140. typedef typename mpl::next<iter1>::type iter2;
  141. typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
  142. typedef typename mpl::next<iter2>::type iter3;
  143. typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
  144. typedef typename mpl::next<iter3>::type iter4;
  145. typedef reverse_fold_impl<
  146. ( (N - 4) < 0 ? 0 : N - 4 )
  147. , iter4
  148. , Last
  149. , fwd_state4
  150. , BackwardOp
  151. , ForwardOp
  152. > nested_chunk;
  153. typedef typename nested_chunk::state bkwd_state4;
  154. typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
  155. typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
  156. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  157. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  158. typedef bkwd_state0 state;
  159. typedef typename nested_chunk::iterator iterator;
  160. };
  161. template<
  162. typename First
  163. , typename Last
  164. , typename State
  165. , typename BackwardOp
  166. , typename ForwardOp
  167. >
  168. struct reverse_fold_impl< -1,First,Last,State,BackwardOp,ForwardOp >
  169. {
  170. typedef reverse_fold_impl<
  171. -1
  172. , typename mpl::next<First>::type
  173. , Last
  174. , typename apply2<ForwardOp,State, typename deref<First>::type>::type
  175. , BackwardOp
  176. , ForwardOp
  177. > nested_step;
  178. typedef typename apply2<
  179. BackwardOp
  180. , typename nested_step::state
  181. , typename deref<First>::type
  182. >::type state;
  183. typedef typename nested_step::iterator iterator;
  184. };
  185. template<
  186. typename Last
  187. , typename State
  188. , typename BackwardOp
  189. , typename ForwardOp
  190. >
  191. struct reverse_fold_impl< -1,Last,Last,State,BackwardOp,ForwardOp >
  192. {
  193. typedef State state;
  194. typedef Last iterator;
  195. };
  196. }}}