function_eval.hpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/phoenix/core/detail/cpp03/preprocessed/function_eval.hpp>
  3. #else
  4. #if !BOOST_PHOENIX_IS_ITERATING
  5. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  6. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/function_eval_" BOOST_PHOENIX_LIMIT_STR ".hpp")
  7. #endif
  8. /*=============================================================================
  9. Copyright (c) 2001-2007 Joel de Guzman
  10. Distributed under the Boost Software License, Version 1.0. (See accompanying
  11. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  12. ==============================================================================*/
  13. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  14. #pragma wave option(preserve: 1)
  15. #endif
  16. #define PHOENIX_GET_ARG(z, n, data) \
  17. typedef \
  18. typename boost::add_reference< \
  19. typename boost::add_const< \
  20. typename boost::result_of< \
  21. boost::phoenix::evaluator( \
  22. BOOST_PP_CAT(A, n) \
  23. , Context \
  24. ) \
  25. >::type \
  26. >::type \
  27. >::type \
  28. BOOST_PP_CAT(a, n);
  29. #define PHOENIX_EVAL_ARG(z, n, data) \
  30. help_rvalue_deduction(boost::phoenix::eval(BOOST_PP_CAT(a, n), ctx))
  31. #define M0(z, n, data) \
  32. typename proto::detail::uncvref<BOOST_PP_CAT(a, n)>::type
  33. #define BOOST_PHOENIX_ITERATION_PARAMS \
  34. (3, (1, BOOST_PP_DEC(BOOST_PHOENIX_ACTOR_LIMIT), \
  35. <boost/phoenix/core/detail/cpp03/function_eval.hpp>))
  36. #include BOOST_PHOENIX_ITERATE()
  37. #undef PHOENIX_GET_ARG
  38. #undef PHOENIX_EVAL_ARG
  39. #undef M0
  40. #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
  41. #pragma wave option(output: null)
  42. #endif
  43. #else
  44. template <
  45. typename This
  46. , typename F
  47. , BOOST_PHOENIX_typename_A
  48. , typename Context
  49. >
  50. struct result<This(F, BOOST_PHOENIX_A, Context)>
  51. {
  52. typedef typename
  53. remove_reference<
  54. typename boost::result_of<evaluator(F, Context)>::type
  55. >::type
  56. fn;
  57. BOOST_PP_REPEAT(BOOST_PHOENIX_ITERATION, PHOENIX_GET_ARG, _)
  58. typedef typename
  59. boost::result_of<fn(BOOST_PHOENIX_a)>::type
  60. type;
  61. /*
  62. typedef typename
  63. mpl::eval_if_c<
  64. has_phx2_result<
  65. fn
  66. , BOOST_PP_ENUM(BOOST_PHOENIX_ITERATION, M0, _)
  67. >::value
  68. , boost::result_of<
  69. fn(
  70. BOOST_PHOENIX_a
  71. )
  72. >
  73. , phx2_result<
  74. fn
  75. , BOOST_PHOENIX_a
  76. >
  77. >::type
  78. type;
  79. */
  80. };
  81. template <typename F, BOOST_PHOENIX_typename_A, typename Context>
  82. typename result<
  83. function_eval(
  84. F const &
  85. , BOOST_PHOENIX_A_ref
  86. , Context const &
  87. )
  88. >::type
  89. operator()(F const & f, BOOST_PHOENIX_A_ref_a, Context const & ctx) const
  90. {
  91. return boost::phoenix::eval(f, ctx)(BOOST_PP_ENUM(BOOST_PHOENIX_ITERATION, PHOENIX_EVAL_ARG, _));
  92. }
  93. template <typename F, BOOST_PHOENIX_typename_A, typename Context>
  94. typename result<
  95. function_eval(
  96. F &
  97. , BOOST_PHOENIX_A_ref
  98. , Context const &
  99. )
  100. >::type
  101. operator()(F & f, BOOST_PHOENIX_A_ref_a, Context const & ctx) const
  102. {
  103. return boost::phoenix::eval(f, ctx)(BOOST_PP_ENUM(BOOST_PHOENIX_ITERATION, PHOENIX_EVAL_ARG, _));
  104. }
  105. #endif
  106. #endif