reverse_fold_impl.hpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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< long N >
  21. struct reverse_fold_chunk;
  22. template<> struct reverse_fold_chunk<0>
  23. {
  24. template<
  25. typename First
  26. , typename Last
  27. , typename State
  28. , typename BackwardOp
  29. , typename ForwardOp
  30. >
  31. struct result_
  32. {
  33. typedef First iter0;
  34. typedef State fwd_state0;
  35. typedef fwd_state0 bkwd_state0;
  36. typedef bkwd_state0 state;
  37. typedef iter0 iterator;
  38. };
  39. /// ETI workaround
  40. template<> struct result_< int,int,int,int,int >
  41. {
  42. typedef int state;
  43. typedef int iterator;
  44. };
  45. };
  46. template<> struct reverse_fold_chunk<1>
  47. {
  48. template<
  49. typename First
  50. , typename Last
  51. , typename State
  52. , typename BackwardOp
  53. , typename ForwardOp
  54. >
  55. struct result_
  56. {
  57. typedef First iter0;
  58. typedef State fwd_state0;
  59. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  60. typedef typename mpl::next<iter0>::type iter1;
  61. typedef fwd_state1 bkwd_state1;
  62. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  63. typedef bkwd_state0 state;
  64. typedef iter1 iterator;
  65. };
  66. /// ETI workaround
  67. template<> struct result_< int,int,int,int,int >
  68. {
  69. typedef int state;
  70. typedef int iterator;
  71. };
  72. };
  73. template<> struct reverse_fold_chunk<2>
  74. {
  75. template<
  76. typename First
  77. , typename Last
  78. , typename State
  79. , typename BackwardOp
  80. , typename ForwardOp
  81. >
  82. struct result_
  83. {
  84. typedef First iter0;
  85. typedef State fwd_state0;
  86. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  87. typedef typename mpl::next<iter0>::type iter1;
  88. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  89. typedef typename mpl::next<iter1>::type iter2;
  90. typedef fwd_state2 bkwd_state2;
  91. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  92. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  93. typedef bkwd_state0 state;
  94. typedef iter2 iterator;
  95. };
  96. /// ETI workaround
  97. template<> struct result_< int,int,int,int,int >
  98. {
  99. typedef int state;
  100. typedef int iterator;
  101. };
  102. };
  103. template<> struct reverse_fold_chunk<3>
  104. {
  105. template<
  106. typename First
  107. , typename Last
  108. , typename State
  109. , typename BackwardOp
  110. , typename ForwardOp
  111. >
  112. struct result_
  113. {
  114. typedef First iter0;
  115. typedef State fwd_state0;
  116. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  117. typedef typename mpl::next<iter0>::type iter1;
  118. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  119. typedef typename mpl::next<iter1>::type iter2;
  120. typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
  121. typedef typename mpl::next<iter2>::type iter3;
  122. typedef fwd_state3 bkwd_state3;
  123. typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
  124. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  125. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  126. typedef bkwd_state0 state;
  127. typedef iter3 iterator;
  128. };
  129. /// ETI workaround
  130. template<> struct result_< int,int,int,int,int >
  131. {
  132. typedef int state;
  133. typedef int iterator;
  134. };
  135. };
  136. template<> struct reverse_fold_chunk<4>
  137. {
  138. template<
  139. typename First
  140. , typename Last
  141. , typename State
  142. , typename BackwardOp
  143. , typename ForwardOp
  144. >
  145. struct result_
  146. {
  147. typedef First iter0;
  148. typedef State fwd_state0;
  149. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  150. typedef typename mpl::next<iter0>::type iter1;
  151. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  152. typedef typename mpl::next<iter1>::type iter2;
  153. typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
  154. typedef typename mpl::next<iter2>::type iter3;
  155. typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
  156. typedef typename mpl::next<iter3>::type iter4;
  157. typedef fwd_state4 bkwd_state4;
  158. typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
  159. typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
  160. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  161. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  162. typedef bkwd_state0 state;
  163. typedef iter4 iterator;
  164. };
  165. /// ETI workaround
  166. template<> struct result_< int,int,int,int,int >
  167. {
  168. typedef int state;
  169. typedef int iterator;
  170. };
  171. };
  172. template< long N >
  173. struct reverse_fold_chunk
  174. {
  175. template<
  176. typename First
  177. , typename Last
  178. , typename State
  179. , typename BackwardOp
  180. , typename ForwardOp
  181. >
  182. struct result_
  183. {
  184. typedef First iter0;
  185. typedef State fwd_state0;
  186. typedef typename apply2< ForwardOp, fwd_state0, typename deref<iter0>::type >::type fwd_state1;
  187. typedef typename mpl::next<iter0>::type iter1;
  188. typedef typename apply2< ForwardOp, fwd_state1, typename deref<iter1>::type >::type fwd_state2;
  189. typedef typename mpl::next<iter1>::type iter2;
  190. typedef typename apply2< ForwardOp, fwd_state2, typename deref<iter2>::type >::type fwd_state3;
  191. typedef typename mpl::next<iter2>::type iter3;
  192. typedef typename apply2< ForwardOp, fwd_state3, typename deref<iter3>::type >::type fwd_state4;
  193. typedef typename mpl::next<iter3>::type iter4;
  194. typedef reverse_fold_impl<
  195. ( (N - 4) < 0 ? 0 : N - 4 )
  196. , iter4
  197. , Last
  198. , fwd_state4
  199. , BackwardOp
  200. , ForwardOp
  201. > nested_chunk;
  202. typedef typename nested_chunk::state bkwd_state4;
  203. typedef typename apply2< BackwardOp, bkwd_state4, typename deref<iter3>::type >::type bkwd_state3;
  204. typedef typename apply2< BackwardOp, bkwd_state3, typename deref<iter2>::type >::type bkwd_state2;
  205. typedef typename apply2< BackwardOp, bkwd_state2, typename deref<iter1>::type >::type bkwd_state1;
  206. typedef typename apply2< BackwardOp, bkwd_state1, typename deref<iter0>::type >::type bkwd_state0;
  207. typedef bkwd_state0 state;
  208. typedef typename nested_chunk::iterator iterator;
  209. };
  210. };
  211. template<
  212. typename First
  213. , typename Last
  214. , typename State
  215. , typename BackwardOp
  216. , typename ForwardOp
  217. >
  218. struct reverse_fold_step;
  219. template<
  220. typename Last
  221. , typename State
  222. >
  223. struct reverse_fold_null_step
  224. {
  225. typedef Last iterator;
  226. typedef State state;
  227. };
  228. template<>
  229. struct reverse_fold_chunk< -1 >
  230. {
  231. template<
  232. typename First
  233. , typename Last
  234. , typename State
  235. , typename BackwardOp
  236. , typename ForwardOp
  237. >
  238. struct result_
  239. {
  240. typedef typename if_<
  241. typename is_same< First,Last >::type
  242. , reverse_fold_null_step< Last,State >
  243. , reverse_fold_step< First,Last,State,BackwardOp,ForwardOp >
  244. >::type res_;
  245. typedef typename res_::state state;
  246. typedef typename res_::iterator iterator;
  247. };
  248. /// ETI workaround
  249. template<> struct result_< int,int,int,int,int >
  250. {
  251. typedef int state;
  252. typedef int iterator;
  253. };
  254. };
  255. template<
  256. typename First
  257. , typename Last
  258. , typename State
  259. , typename BackwardOp
  260. , typename ForwardOp
  261. >
  262. struct reverse_fold_step
  263. {
  264. typedef reverse_fold_chunk< -1 >::template result_<
  265. typename mpl::next<First>::type
  266. , Last
  267. , typename apply2<ForwardOp,State, typename deref<First>::type>::type
  268. , BackwardOp
  269. , ForwardOp
  270. > nested_step;
  271. typedef typename apply2<
  272. BackwardOp
  273. , typename nested_step::state
  274. , typename deref<First>::type
  275. >::type state;
  276. typedef typename nested_step::iterator iterator;
  277. };
  278. template<
  279. long N
  280. , typename First
  281. , typename Last
  282. , typename State
  283. , typename BackwardOp
  284. , typename ForwardOp
  285. >
  286. struct reverse_fold_impl
  287. : reverse_fold_chunk<N>
  288. ::template result_< First,Last,State,BackwardOp,ForwardOp >
  289. {
  290. };
  291. }}}