make_gcc_workaround.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0)
  3. #include <boost/proto/transform/detail/preprocessed/make_gcc_workaround.hpp>
  4. #endif
  5. #elif !defined(BOOST_PP_IS_ITERATING)
  6. #define BOOST_PROTO_EXPR_MAKE_ARG(Z, M, DATA) \
  7. detail::as_lvalue( \
  8. typename when<_, BOOST_PP_CAT(A, M)>::template impl<Expr, State, Data>()(e, s, d) \
  9. ) \
  10. /**/
  11. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  12. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make_gcc_workaround.hpp")
  13. #endif
  14. ///////////////////////////////////////////////////////////////////////////////
  15. /// \file make_gcc_workaround.hpp
  16. /// Special workaround code to make the make\<\> transform work on certain
  17. /// versions of gcc.
  18. //
  19. // Copyright 2008 Eric Niebler. Distributed under the Boost
  20. // Software License, Version 1.0. (See accompanying file
  21. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  22. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  23. #pragma wave option(preserve: 1)
  24. #endif
  25. #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0) || \
  26. (defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES))
  27. #define BOOST_PP_ITERATION_PARAMS_1 \
  28. (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/make_gcc_workaround.hpp>))
  29. #include BOOST_PP_ITERATE()
  30. #endif
  31. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  32. #pragma wave option(output: null)
  33. #endif
  34. #undef BOOST_PROTO_EXPR_MAKE_ARG
  35. #else
  36. #define N BOOST_PP_ITERATION()
  37. // work around GCC bug
  38. template<typename Tag, typename Args, long Arity BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  39. struct make<proto::expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))>
  40. : transform<make<proto::expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))> >
  41. {
  42. template<typename Expr, typename State, typename Data>
  43. struct impl : transform_impl<Expr, State, Data>
  44. {
  45. typedef proto::expr<Tag, Args, Arity> result_type;
  46. BOOST_FORCEINLINE
  47. result_type operator ()(
  48. typename impl::expr_param e
  49. , typename impl::state_param s
  50. , typename impl::data_param d
  51. ) const
  52. {
  53. return proto::expr<Tag, Args, Arity>::make(
  54. BOOST_PP_ENUM(N, BOOST_PROTO_EXPR_MAKE_ARG, DATA)
  55. );
  56. }
  57. };
  58. };
  59. template<typename Tag, typename Args, long Arity BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  60. struct make<proto::basic_expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))>
  61. : transform<make<proto::basic_expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))> >
  62. {
  63. template<typename Expr, typename State, typename Data>
  64. struct impl : transform_impl<Expr, State, Data>
  65. {
  66. typedef proto::basic_expr<Tag, Args, Arity> result_type;
  67. BOOST_FORCEINLINE
  68. result_type operator ()(
  69. typename impl::expr_param e
  70. , typename impl::state_param s
  71. , typename impl::data_param d
  72. ) const
  73. {
  74. return proto::basic_expr<Tag, Args, Arity>::make(
  75. BOOST_PP_ENUM(N, BOOST_PROTO_EXPR_MAKE_ARG, DATA)
  76. );
  77. }
  78. };
  79. };
  80. #undef N
  81. #endif