pass_through_impl.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/transform/detail/preprocessed/pass_through_impl.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #define BOOST_PROTO_DEFINE_TRANSFORM_TYPE(Z, N, DATA) \
  5. typename Grammar::BOOST_PP_CAT(proto_child, N)::template impl< \
  6. typename result_of::child_c<Expr, N>::type \
  7. , State \
  8. , Data \
  9. >::result_type \
  10. /**/
  11. #define BOOST_PROTO_DEFINE_TRANSFORM(Z, N, DATA) \
  12. typename Grammar::BOOST_PP_CAT(proto_child, N)::template impl< \
  13. typename result_of::child_c<Expr, N>::type \
  14. , State \
  15. , Data \
  16. >()( \
  17. e.proto_base().BOOST_PP_CAT(child, N), s, d \
  18. ) \
  19. /**/
  20. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  21. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/pass_through_impl.hpp")
  22. #endif
  23. ///////////////////////////////////////////////////////////////////////////////
  24. /// \file pass_through_impl.hpp
  25. ///
  26. /// Specializations of pass_through_impl, used in the implementation of the
  27. /// pass_through transform.
  28. //
  29. // Copyright 2008 Eric Niebler. Distributed under the Boost
  30. // Software License, Version 1.0. (See accompanying file
  31. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  32. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  33. #pragma wave option(preserve: 1)
  34. #endif
  35. #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/pass_through_impl.hpp>))
  36. #include BOOST_PP_ITERATE()
  37. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  38. #pragma wave option(output: null)
  39. #endif
  40. #undef BOOST_PROTO_DEFINE_TRANSFORM
  41. #undef BOOST_PROTO_DEFINE_TRANSFORM_TYPE
  42. #else
  43. #define N BOOST_PP_ITERATION()
  44. template<typename Grammar, typename Domain, typename Expr, typename State, typename Data>
  45. struct pass_through_impl<Grammar, Domain, Expr, State, Data, N>
  46. : transform_impl<Expr, State, Data>
  47. {
  48. typedef typename pass_through_impl::expr unref_expr;
  49. typedef
  50. typename mpl::if_c<
  51. is_same<Domain, deduce_domain>::value
  52. , typename unref_expr::proto_domain
  53. , Domain
  54. >::type
  55. result_domain;
  56. typedef
  57. typename base_expr<
  58. result_domain
  59. , typename unref_expr::proto_tag
  60. , BOOST_PP_CAT(list, N)<
  61. BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM_TYPE, ~)
  62. >
  63. >::type
  64. expr_type;
  65. typedef typename result_domain::proto_generator proto_generator;
  66. typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type;
  67. BOOST_FORCEINLINE
  68. BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const)
  69. operator ()(
  70. typename pass_through_impl::expr_param e
  71. , typename pass_through_impl::state_param s
  72. , typename pass_through_impl::data_param d
  73. ) const
  74. {
  75. expr_type const that = {
  76. BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM, ~)
  77. };
  78. // Without this, MSVC complains that "that" is uninitialized,
  79. // and it actually triggers a runtime check in debug mode when
  80. // built with VC8.
  81. detail::ignore_unused(&that);
  82. return proto_generator()(that);
  83. }
  84. };
  85. #undef N
  86. #endif