make_expr_.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/detail/preprocessed/make_expr_.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/make_expr_.hpp")
  6. #endif
  7. ///////////////////////////////////////////////////////////////////////////////
  8. /// \file make_expr_.hpp
  9. /// Contains definition of make_expr_\<\> class template.
  10. //
  11. // Copyright 2008 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. template<
  18. typename Tag
  19. , typename Domain
  20. BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
  21. BOOST_PROTO_MAX_ARITY
  22. , typename A
  23. , = void BOOST_PP_INTERCEPT
  24. )
  25. , typename _ = void
  26. >
  27. struct make_expr_
  28. {};
  29. template<typename Domain, typename A>
  30. struct make_expr_<tag::terminal, Domain, A
  31. BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, void BOOST_PP_INTERCEPT)>
  32. {
  33. typedef typename proto::detail::protoify<A, Domain>::result_type result_type;
  34. BOOST_FORCEINLINE
  35. result_type operator()(typename add_reference<A>::type a) const
  36. {
  37. return proto::detail::protoify<A, Domain>()(a);
  38. }
  39. };
  40. template<typename A>
  41. struct make_expr_<tag::terminal, deduce_domain, A
  42. BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, void BOOST_PP_INTERCEPT)>
  43. : make_expr_<tag::terminal, default_domain, A>
  44. {};
  45. #define BOOST_PP_ITERATION_PARAMS_1 \
  46. (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/make_expr_.hpp>))
  47. #include BOOST_PP_ITERATE()
  48. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  49. #pragma wave option(output: null)
  50. #endif
  51. #else // BOOST_PP_IS_ITERATING
  52. #define N BOOST_PP_ITERATION()
  53. #define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N)
  54. template<typename Tag, typename Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  55. struct make_expr_<Tag, Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
  56. BOOST_PP_ENUM_TRAILING_PARAMS(M, void BOOST_PP_INTERCEPT), void>
  57. {
  58. typedef
  59. BOOST_PP_CAT(list, N)<
  60. BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD_TYPE, (A, ~, Domain))
  61. >
  62. proto_args;
  63. typedef typename base_expr<Domain, Tag, proto_args>::type expr_type;
  64. typedef typename Domain::proto_generator proto_generator;
  65. typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
  66. BOOST_FORCEINLINE
  67. result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, typename add_reference<A, >::type a)) const
  68. {
  69. expr_type const that = {
  70. BOOST_PP_ENUM(N, BOOST_PROTO_AS_CHILD, (A, a, Domain))
  71. };
  72. return proto_generator()(that);
  73. }
  74. };
  75. template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
  76. struct make_expr_<Tag, deduce_domain BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
  77. BOOST_PP_ENUM_TRAILING_PARAMS(M, void BOOST_PP_INTERCEPT), void>
  78. : make_expr_<
  79. Tag
  80. , typename BOOST_PP_CAT(deduce_domain, N)<BOOST_PP_ENUM_PARAMS(N, A)>::type
  81. BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
  82. >
  83. {};
  84. #undef N
  85. #undef M
  86. #endif