fold_impl.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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_/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 fold_impl;
  19. template<
  20. typename First
  21. , typename Last
  22. , typename State
  23. , typename ForwardOp
  24. >
  25. struct fold_impl< 0,First,Last,State,ForwardOp >
  26. {
  27. typedef First iter0;
  28. typedef State state0;
  29. typedef state0 state;
  30. typedef iter0 iterator;
  31. };
  32. template<
  33. typename First
  34. , typename Last
  35. , typename State
  36. , typename ForwardOp
  37. >
  38. struct fold_impl< 1,First,Last,State,ForwardOp >
  39. {
  40. typedef First iter0;
  41. typedef State state0;
  42. typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
  43. typedef typename mpl::next<iter0>::type iter1;
  44. typedef state1 state;
  45. typedef iter1 iterator;
  46. };
  47. template<
  48. typename First
  49. , typename Last
  50. , typename State
  51. , typename ForwardOp
  52. >
  53. struct fold_impl< 2,First,Last,State,ForwardOp >
  54. {
  55. typedef First iter0;
  56. typedef State state0;
  57. typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
  58. typedef typename mpl::next<iter0>::type iter1;
  59. typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
  60. typedef typename mpl::next<iter1>::type iter2;
  61. typedef state2 state;
  62. typedef iter2 iterator;
  63. };
  64. template<
  65. typename First
  66. , typename Last
  67. , typename State
  68. , typename ForwardOp
  69. >
  70. struct fold_impl< 3,First,Last,State,ForwardOp >
  71. {
  72. typedef First iter0;
  73. typedef State state0;
  74. typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
  75. typedef typename mpl::next<iter0>::type iter1;
  76. typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
  77. typedef typename mpl::next<iter1>::type iter2;
  78. typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
  79. typedef typename mpl::next<iter2>::type iter3;
  80. typedef state3 state;
  81. typedef iter3 iterator;
  82. };
  83. template<
  84. typename First
  85. , typename Last
  86. , typename State
  87. , typename ForwardOp
  88. >
  89. struct fold_impl< 4,First,Last,State,ForwardOp >
  90. {
  91. typedef First iter0;
  92. typedef State state0;
  93. typedef typename apply2< ForwardOp, state0, typename deref<iter0>::type >::type state1;
  94. typedef typename mpl::next<iter0>::type iter1;
  95. typedef typename apply2< ForwardOp, state1, typename deref<iter1>::type >::type state2;
  96. typedef typename mpl::next<iter1>::type iter2;
  97. typedef typename apply2< ForwardOp, state2, typename deref<iter2>::type >::type state3;
  98. typedef typename mpl::next<iter2>::type iter3;
  99. typedef typename apply2< ForwardOp, state3, typename deref<iter3>::type >::type state4;
  100. typedef typename mpl::next<iter3>::type iter4;
  101. typedef state4 state;
  102. typedef iter4 iterator;
  103. };
  104. template<
  105. int N
  106. , typename First
  107. , typename Last
  108. , typename State
  109. , typename ForwardOp
  110. >
  111. struct fold_impl
  112. {
  113. typedef fold_impl<
  114. 4
  115. , First
  116. , Last
  117. , State
  118. , ForwardOp
  119. > chunk_;
  120. typedef fold_impl<
  121. ( (N - 4) < 0 ? 0 : N - 4 )
  122. , typename chunk_::iterator
  123. , Last
  124. , typename chunk_::state
  125. , ForwardOp
  126. > res_;
  127. typedef typename res_::state state;
  128. typedef typename res_::iterator iterator;
  129. };
  130. template<
  131. typename First
  132. , typename Last
  133. , typename State
  134. , typename ForwardOp
  135. >
  136. struct fold_impl< -1,First,Last,State,ForwardOp >
  137. : fold_impl<
  138. -1
  139. , typename mpl::next<First>::type
  140. , Last
  141. , typename apply2<ForwardOp,State, typename deref<First>::type>::type
  142. , ForwardOp
  143. >
  144. {
  145. };
  146. template<
  147. typename Last
  148. , typename State
  149. , typename ForwardOp
  150. >
  151. struct fold_impl< -1,Last,Last,State,ForwardOp >
  152. {
  153. typedef State state;
  154. typedef Last iterator;
  155. };
  156. }}}