funop.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/detail/preprocessed/funop.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #define BOOST_PROTO_AS_CHILD_TYPE(Z, N, DATA) \
  5. typename proto::result_of::as_child<BOOST_PP_CAT(A, N), Domain>::type \
  6. /**/
  7. #define BOOST_PROTO_AS_CHILD(Z, N, DATA) \
  8. proto::as_child<Domain>(BOOST_PP_CAT(a, N)) \
  9. /**/
  10. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  11. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/funop.hpp")
  12. #endif
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // funop.hpp
  15. // Contains definition of funop[n]\<\> class template.
  16. //
  17. // Copyright 2008 Eric Niebler. Distributed under the Boost
  18. // Software License, Version 1.0. (See accompanying file
  19. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  20. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  21. #pragma wave option(preserve: 1)
  22. #endif
  23. #define BOOST_PP_ITERATION_PARAMS_1 \
  24. (3, (0, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY), <boost/proto/detail/funop.hpp>))
  25. #include BOOST_PP_ITERATE()
  26. #undef BOOST_PROTO_AS_CHILD
  27. #undef BOOST_PROTO_AS_CHILD_TYPE
  28. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  29. #pragma wave option(output: null)
  30. #endif
  31. #else
  32. /// \brief A helper metafunction for computing the
  33. /// return type of \c proto::expr\<\>::operator().
  34. template<typename Expr, typename Domain BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename A)>
  35. struct BOOST_PP_CAT(funop, BOOST_PP_ITERATION())
  36. {
  37. typedef typename proto::base_expr<
  38. Domain
  39. , tag::function
  40. , BOOST_PP_CAT(list, BOOST_PP_INC(BOOST_PP_ITERATION()))<
  41. Expr &
  42. BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION(), BOOST_PROTO_AS_CHILD_TYPE, ~)
  43. >
  44. >::type type;
  45. BOOST_FORCEINLINE
  46. static type const call(
  47. Expr &e
  48. BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), A, &a)
  49. )
  50. {
  51. type that = {
  52. e
  53. BOOST_PP_ENUM_TRAILING(BOOST_PP_ITERATION(), BOOST_PROTO_AS_CHILD, ~)
  54. };
  55. return that;
  56. }
  57. };
  58. /// \brief A helper metafunction for computing the
  59. /// return type of \c proto::expr\<\>::operator().
  60. template<typename Expr BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename A), typename This, typename Domain>
  61. struct funop<Expr(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), A)), This, Domain>
  62. : BOOST_PP_CAT(funop, BOOST_PP_ITERATION())<
  63. typename detail::same_cv<Expr, This>::type
  64. , Domain
  65. BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
  66. BOOST_PP_ITERATION()
  67. , typename remove_reference<A
  68. , >::type BOOST_PP_INTERCEPT
  69. )
  70. >
  71. {};
  72. #endif // BOOST_PROTO_DONT_USE_PREPROCESSED_FILES