pack_impl.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/transform/detail/preprocessed/pack_impl.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  5. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/pack_impl.hpp")
  6. #endif
  7. ///////////////////////////////////////////////////////////////////////////////
  8. /// \file pack_impl.hpp
  9. /// Contains helpers for pseudo-pack expansion.
  10. //
  11. // Copyright 2012 Eric Niebler. Distributed under the Boost
  12. // Software License, Version 1.0. (See accompanying file
  13. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  14. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  15. #pragma wave option(preserve: 1)
  16. #endif
  17. #define BOOST_PP_ITERATION_PARAMS_1 \
  18. (3, (0, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), <boost/proto/transform/detail/pack_impl.hpp>))
  19. #include BOOST_PP_ITERATE()
  20. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  21. #pragma wave option(output: null)
  22. #endif
  23. #else
  24. #if BOOST_PP_ITERATION_DEPTH() == 1
  25. #define N BOOST_PP_ITERATION()
  26. #define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N)
  27. #define M0(Z, X, D) typename expand_pattern_helper<proto::_child_c<X>, Fun>::type
  28. template<typename Fun, typename Cont>
  29. struct expand_pattern<BOOST_PP_INC(N), Fun, Cont>
  30. : Cont::template cat<BOOST_PP_ENUM(BOOST_PP_INC(N), M0, ~)>
  31. {
  32. BOOST_MPL_ASSERT_MSG(
  33. (expand_pattern_helper<proto::_child_c<0>, Fun>::applied::value)
  34. , NO_PACK_EXPRESSION_FOUND_IN_UNPACKING_PATTERN
  35. , (Fun)
  36. );
  37. };
  38. template<typename Ret BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  39. struct BOOST_PP_CAT(expand_pattern_rest_, N)
  40. {
  41. template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(M), typename C, void)>
  42. struct cat;
  43. #define BOOST_PP_ITERATION_PARAMS_2 \
  44. (3, (1, M, <boost/proto/transform/detail/pack_impl.hpp>))
  45. #include BOOST_PP_ITERATE()
  46. };
  47. #undef M0
  48. #undef M
  49. #undef N
  50. #else
  51. #define I BOOST_PP_ITERATION()
  52. #define J BOOST_PP_RELATIVE_ITERATION(1)
  53. template<BOOST_PP_ENUM_PARAMS(I, typename C)>
  54. struct cat<BOOST_PP_ENUM_PARAMS(I, C)>
  55. {
  56. typedef msvc_fun_workaround<Ret(BOOST_PP_ENUM_PARAMS(J, A) BOOST_PP_COMMA_IF(J) BOOST_PP_ENUM_PARAMS(I, C))> type;
  57. };
  58. #undef J
  59. #undef I
  60. #endif
  61. #endif