default_eval.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/context/detail/preprocessed/default_eval.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #define BOOST_PROTO_DEFAULT_EVAL_SHIFTED(Z, M, DATA) \
  5. BOOST_PROTO_DEFAULT_EVAL(Z, BOOST_PP_ADD(M, 2), DATA) \
  6. /**/
  7. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  8. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/default_eval.hpp")
  9. #endif
  10. ///////////////////////////////////////////////////////////////////////////////
  11. /// \file default_eval.hpp
  12. /// Contains specializations of the default_eval\<\> class template.
  13. //
  14. // Copyright 2008 Eric Niebler. Distributed under the Boost
  15. // Software License, Version 1.0. (See accompanying file
  16. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  17. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  18. #pragma wave option(preserve: 1)
  19. #endif
  20. #define BOOST_PP_ITERATION_PARAMS_1 \
  21. (3, (3, BOOST_PROTO_MAX_ARITY, <boost/proto/context/detail/default_eval.hpp>))
  22. #include BOOST_PP_ITERATE()
  23. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  24. #pragma wave option(output: null)
  25. #endif
  26. #undef BOOST_PROTO_DEFAULT_EVAL_SHIFTED
  27. #else
  28. #define N BOOST_PP_ITERATION()
  29. template<typename Expr, typename Context>
  30. struct default_eval<Expr, Context, proto::tag::function, N>
  31. {
  32. typedef
  33. typename proto::detail::result_of_fixup<
  34. BOOST_PROTO_DEFAULT_EVAL_TYPE(~, 0, Expr)
  35. >::type
  36. function_type;
  37. typedef
  38. typename BOOST_PROTO_RESULT_OF<
  39. function_type(BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFAULT_EVAL_TYPE, Expr))
  40. >::type
  41. result_type;
  42. result_type operator ()(Expr &expr, Context &context) const
  43. {
  44. return this->invoke(expr, context, is_member_function_pointer<function_type>());
  45. }
  46. private:
  47. result_type invoke(Expr &expr, Context &context, mpl::false_) const
  48. {
  49. return BOOST_PROTO_DEFAULT_EVAL(~, 0, expr)(
  50. BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFAULT_EVAL, expr)
  51. );
  52. }
  53. result_type invoke(Expr &expr, Context &context, mpl::true_) const
  54. {
  55. BOOST_PROTO_USE_GET_POINTER();
  56. typedef typename detail::class_member_traits<function_type>::class_type class_type;
  57. return (
  58. BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, expr))) ->*
  59. BOOST_PROTO_DEFAULT_EVAL(~, 0, expr)
  60. )(BOOST_PP_ENUM(BOOST_PP_SUB(N, 2), BOOST_PROTO_DEFAULT_EVAL_SHIFTED, expr));
  61. }
  62. };
  63. #undef N
  64. #endif