advance_backward.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #if !defined(BOOST_PP_IS_ITERATING)
  2. ///// header body
  3. #ifndef BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
  4. #define BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
  5. // Copyright Aleksey Gurtovoy 2000-2004
  6. //
  7. // Distributed under the Boost Software License, Version 1.0.
  8. // (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // See http://www.boost.org/libs/mpl for documentation.
  12. // $Id$
  13. // $Date$
  14. // $Revision$
  15. #if !defined(BOOST_MPL_PREPROCESSING_MODE)
  16. # include <boost/mpl/prior.hpp>
  17. # include <boost/mpl/apply_wrap.hpp>
  18. #endif
  19. #include <boost/mpl/aux_/config/use_preprocessed.hpp>
  20. #if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
  21. && !defined(BOOST_MPL_PREPROCESSING_MODE)
  22. # define BOOST_MPL_PREPROCESSED_HEADER advance_backward.hpp
  23. # include <boost/mpl/aux_/include_preprocessed.hpp>
  24. #else
  25. # include <boost/mpl/limits/unrolling.hpp>
  26. # include <boost/mpl/aux_/nttp_decl.hpp>
  27. # include <boost/mpl/aux_/config/eti.hpp>
  28. # include <boost/preprocessor/iterate.hpp>
  29. # include <boost/preprocessor/cat.hpp>
  30. # include <boost/preprocessor/inc.hpp>
  31. namespace boost { namespace mpl { namespace aux {
  32. // forward declaration
  33. template< BOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_backward;
  34. # define BOOST_PP_ITERATION_PARAMS_1 \
  35. (3,(0, BOOST_MPL_LIMIT_UNROLLING, <boost/mpl/aux_/advance_backward.hpp>))
  36. # include BOOST_PP_ITERATE()
  37. // implementation for N that exceeds BOOST_MPL_LIMIT_UNROLLING
  38. template< BOOST_MPL_AUX_NTTP_DECL(long, N) >
  39. struct advance_backward
  40. {
  41. template< typename Iterator > struct apply
  42. {
  43. typedef typename apply_wrap1<
  44. advance_backward<BOOST_MPL_LIMIT_UNROLLING>
  45. , Iterator
  46. >::type chunk_result_;
  47. typedef typename apply_wrap1<
  48. advance_backward<(
  49. (N - BOOST_MPL_LIMIT_UNROLLING) < 0
  50. ? 0
  51. : N - BOOST_MPL_LIMIT_UNROLLING
  52. )>
  53. , chunk_result_
  54. >::type type;
  55. };
  56. };
  57. }}}
  58. #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
  59. #endif // BOOST_MPL_AUX778076_ADVANCE_BACKWARD_HPP_INCLUDED
  60. ///// iteration, depth == 1
  61. // For gcc 4.4 compatability, we must include the
  62. // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
  63. #else // BOOST_PP_IS_ITERATING
  64. #if BOOST_PP_ITERATION_DEPTH() == 1
  65. #define i_ BOOST_PP_FRAME_ITERATION(1)
  66. template<>
  67. struct advance_backward< BOOST_PP_FRAME_ITERATION(1) >
  68. {
  69. template< typename Iterator > struct apply
  70. {
  71. typedef Iterator iter0;
  72. #if i_ > 0
  73. # define BOOST_PP_ITERATION_PARAMS_2 \
  74. (3,(1, BOOST_PP_FRAME_ITERATION(1), <boost/mpl/aux_/advance_backward.hpp>))
  75. # include BOOST_PP_ITERATE()
  76. #endif
  77. typedef BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(1)) type;
  78. };
  79. #if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
  80. /// ETI workaround
  81. template<> struct apply<int>
  82. {
  83. typedef int type;
  84. };
  85. #endif
  86. };
  87. #undef i_
  88. ///// iteration, depth == 2
  89. #elif BOOST_PP_ITERATION_DEPTH() == 2
  90. # define AUX778076_ITER_0 BOOST_PP_CAT(iter,BOOST_PP_DEC(BOOST_PP_FRAME_ITERATION(2)))
  91. # define AUX778076_ITER_1 BOOST_PP_CAT(iter,BOOST_PP_FRAME_ITERATION(2))
  92. typedef typename prior<AUX778076_ITER_0>::type AUX778076_ITER_1;
  93. # undef AUX778076_ITER_1
  94. # undef AUX778076_ITER_0
  95. #endif // BOOST_PP_ITERATION_DEPTH()
  96. #endif // BOOST_PP_IS_ITERATING