actor_operator.hpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
  2. #ifndef BOOST_PHOENIX_CORE_DETAIL_ACTOR_OPERATOR_HPP
  3. #define BOOST_PHOENIX_CORE_DETAIL_ACTOR_OPERATOR_HPP
  4. #include <boost/phoenix/support/iterate.hpp>
  5. #include <boost/phoenix/core/detail/cpp03/preprocessed/actor_operator.hpp>
  6. #endif
  7. #else
  8. #if !BOOST_PHOENIX_IS_ITERATING
  9. #ifndef BOOST_PHOENIX_CORE_DETAIL_ACTOR_OPERATOR_HPP
  10. #define BOOST_PHOENIX_CORE_DETAIL_ACTOR_OPERATOR_HPP
  11. #include <boost/phoenix/support/iterate.hpp>
  12. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  13. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/actor_operator_" BOOST_PHOENIX_LIMIT_STR ".hpp")
  14. #endif
  15. /*==============================================================================
  16. Copyright (c) 2005-2010 Joel de Guzman
  17. Copyright (c) 2010 Thomas Heller
  18. Distributed under the Boost Software License, Version 1.0. (See accompanying
  19. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  20. ==============================================================================*/
  21. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  22. #pragma wave option(preserve: 1)
  23. #endif
  24. #define M0(Z, N, D) \
  25. typename detail::result_type_deduction_helper<BOOST_PP_CAT(A, N)>::type \
  26. /**/
  27. #define BOOST_PHOENIX_ITERATION_PARAMS \
  28. (3, (1, BOOST_PHOENIX_ACTOR_LIMIT, \
  29. <boost/phoenix/core/detail/cpp03/actor_operator.hpp>))
  30. #include BOOST_PHOENIX_ITERATE()
  31. #undef M0
  32. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  33. #pragma wave option(output: null)
  34. #endif
  35. #endif
  36. #else
  37. #if BOOST_PHOENIX_ITERATION >= BOOST_PHOENIX_PERFECT_FORWARD_LIMIT
  38. template <typename This, BOOST_PHOENIX_typename_A>
  39. struct result<This(BOOST_PHOENIX_A)>
  40. : result<This(BOOST_PHOENIX_A_const_ref)>
  41. {};
  42. template <typename This, BOOST_PHOENIX_typename_A>
  43. struct result<This(BOOST_PHOENIX_A_ref)>
  44. : result_of::actor<proto_base_expr, BOOST_PHOENIX_A_ref>
  45. {};
  46. template <BOOST_PHOENIX_typename_A>
  47. typename result_of::actor<proto_base_expr, BOOST_PHOENIX_A_ref>::type
  48. operator()(BOOST_PHOENIX_A_ref_a)
  49. {
  50. typedef
  51. BOOST_PP_CAT(vector, BOOST_PP_INC(BOOST_PHOENIX_ITERATION))<
  52. const actor<Expr> *, BOOST_PHOENIX_A_ref
  53. >
  54. env_type;
  55. env_type env = {this, BOOST_PHOENIX_a};
  56. return phoenix::eval(*this, phoenix::context(env, default_actions()));
  57. }
  58. template <BOOST_PHOENIX_typename_A>
  59. typename result_of::actor<proto_base_expr, BOOST_PHOENIX_A_ref>::type
  60. operator()(BOOST_PHOENIX_A_ref_a) const
  61. {
  62. typedef
  63. BOOST_PP_CAT(vector, BOOST_PP_INC(BOOST_PHOENIX_ITERATION))<
  64. const actor<Expr> *, BOOST_PHOENIX_A_ref
  65. >
  66. env_type;
  67. env_type env = {this, BOOST_PHOENIX_a};
  68. return phoenix::eval(*this, phoenix::context(env, default_actions()));
  69. }
  70. template <BOOST_PHOENIX_typename_A>
  71. typename result_of::actor<proto_base_expr, BOOST_PHOENIX_A_const_ref>::type
  72. operator()(BOOST_PHOENIX_A_const_ref_a)
  73. {
  74. typedef
  75. BOOST_PP_CAT(vector, BOOST_PP_INC(BOOST_PHOENIX_ITERATION))<
  76. const actor<Expr> *, BOOST_PHOENIX_A_const_ref
  77. >
  78. env_type;
  79. env_type env = {this, BOOST_PHOENIX_a};
  80. return phoenix::eval(*this, phoenix::context(env, default_actions()));
  81. }
  82. template <BOOST_PHOENIX_typename_A>
  83. typename result_of::actor<proto_base_expr, BOOST_PHOENIX_A_const_ref>::type
  84. operator()(BOOST_PHOENIX_A_const_ref_a) const
  85. {
  86. typedef
  87. BOOST_PP_CAT(vector, BOOST_PP_INC(BOOST_PHOENIX_ITERATION))<
  88. const actor<Expr> *, BOOST_PHOENIX_A_const_ref
  89. >
  90. env_type;
  91. env_type env = {this, BOOST_PHOENIX_a};
  92. return phoenix::eval(*this, phoenix::context(env, default_actions()));
  93. }
  94. #else
  95. // We need to define operator() for all permutations of reference types.
  96. // For BOOST_PHOENIX_ITERATION <= BOOST_PHOENIX_LIMIT_PREFECT_FORWARD
  97. // 2^BOOST_PHOENIX_ITERATION overloads are created
  98. // For compile time reasons,
  99. // if BOOST_PHOENIX_ITERATION > BOOST_PHOENIX_LIMIT_PERFECT_FORWARD
  100. // only operator()(A const &...a) and operator()(A &...a) are generated
  101. // this is all handled by the PP mumbo jumbo above
  102. #define BOOST_PHOENIX_ACTOR_OPERATOR(_, I, __) \
  103. template <typename This, BOOST_PHOENIX_typename_A> \
  104. struct result<This(BOOST_PHOENIX_PERM_A(I))> \
  105. : result_of::actor<proto_base_expr, BOOST_PHOENIX_PERM_A(I)> \
  106. {}; \
  107. \
  108. template <BOOST_PHOENIX_typename_A> \
  109. typename result_of::actor<proto_base_expr, BOOST_PHOENIX_PERM_A(I)>::type\
  110. operator()(BOOST_PHOENIX_PERM_A_a(I)) const \
  111. { \
  112. typedef \
  113. BOOST_PP_CAT(vector, BOOST_PP_INC(BOOST_PHOENIX_ITERATION))< \
  114. const actor<Expr> *, BOOST_PHOENIX_PERM_A(I) \
  115. > \
  116. env_type; \
  117. env_type env = {this, BOOST_PHOENIX_a}; \
  118. \
  119. return phoenix::eval(*this, phoenix::context(env, default_actions()));\
  120. } \
  121. \
  122. template <BOOST_PHOENIX_typename_A> \
  123. typename result_of::actor<proto_base_expr, BOOST_PHOENIX_PERM_A(I)>::type\
  124. operator()(BOOST_PHOENIX_PERM_A_a(I)) \
  125. { \
  126. typedef \
  127. BOOST_PP_CAT(vector, BOOST_PP_INC(BOOST_PHOENIX_ITERATION))< \
  128. const actor<Expr> *, BOOST_PHOENIX_PERM_A(I) \
  129. > \
  130. env_type; \
  131. env_type env = {this, BOOST_PHOENIX_a}; \
  132. \
  133. return phoenix::eval(*this, phoenix::context(env, default_actions()));\
  134. } \
  135. /**/
  136. template <typename This, BOOST_PHOENIX_typename_A>
  137. struct result<This(BOOST_PHOENIX_A)>
  138. : result<This(BOOST_PP_ENUM(BOOST_PHOENIX_ITERATION, M0, _))>
  139. {};
  140. BOOST_PP_REPEAT(BOOST_PHOENIX_PERM_SIZE, BOOST_PHOENIX_ACTOR_OPERATOR, _)
  141. #undef BOOST_PHOENIX_ACTOR_OPERATOR
  142. #endif
  143. #endif
  144. #endif // BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES