matches_.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/detail/preprocessed/matches_.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #define BOOST_PROTO_MATCHES_N_FUN(Z, N, DATA) \
  5. matches_< \
  6. typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_derived_expr \
  7. , typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_grammar \
  8. , typename Args2::BOOST_PP_CAT(child, N)::proto_grammar \
  9. >
  10. #define BOOST_PROTO_DEFINE_MATCHES(Z, N, DATA) \
  11. matches_< \
  12. Expr \
  13. , BasicExpr \
  14. , typename BOOST_PP_CAT(G, N)::proto_grammar \
  15. >
  16. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  17. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/matches_.hpp")
  18. #endif
  19. ///////////////////////////////////////////////////////////////////////////////
  20. /// \file matches_.hpp
  21. /// Definitions of matches_ specializations
  22. //
  23. // Copyright 2008 Eric Niebler. Distributed under the Boost
  24. // Software License, Version 1.0. (See accompanying file
  25. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  26. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  27. #pragma wave option(preserve: 1)
  28. #endif
  29. #define BOOST_PP_ITERATION_PARAMS_1 \
  30. (3, (2, BOOST_PP_MAX(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_MAX_LOGICAL_ARITY), <boost/proto/detail/matches_.hpp>))
  31. #include BOOST_PP_ITERATE()
  32. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  33. #pragma wave option(output: null)
  34. #endif
  35. #undef BOOST_PROTO_DEFINE_MATCHES
  36. #undef BOOST_PROTO_MATCHES_N_FUN
  37. #else // BOOST_PP_IS_ITERATING
  38. #define N BOOST_PP_ITERATION()
  39. #if N <= BOOST_PROTO_MAX_LOGICAL_ARITY
  40. // handle proto::or_
  41. template<typename Expr, typename BasicExpr BOOST_PP_ENUM_TRAILING_PARAMS(N, typename G)>
  42. struct matches_<Expr, BasicExpr, proto::or_<BOOST_PP_ENUM_PARAMS(N, G)> >
  43. : BOOST_PP_CAT(or_, N)<
  44. matches_<Expr, BasicExpr, typename G0::proto_grammar>::value,
  45. Expr, BasicExpr BOOST_PP_ENUM_TRAILING_PARAMS(N, G)
  46. >
  47. {};
  48. // handle proto::and_
  49. template<typename Expr, typename BasicExpr, BOOST_PP_ENUM_PARAMS(N, typename G)>
  50. struct matches_<Expr, BasicExpr, proto::and_<BOOST_PP_ENUM_PARAMS(N, G)> >
  51. : detail::BOOST_PP_CAT(and_, N)<
  52. BOOST_PROTO_DEFINE_MATCHES(~, 0, ~)::value,
  53. BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_DEFINE_MATCHES, ~)
  54. >
  55. {};
  56. #endif
  57. #if N <= BOOST_PROTO_MAX_ARITY
  58. template<typename Expr, typename Tag, typename Args1, typename Args2>
  59. struct matches_< Expr, proto::basic_expr<Tag, Args1, N>, proto::basic_expr<Tag, Args2, N> >
  60. : BOOST_PP_CAT(and_, N)<
  61. BOOST_PROTO_MATCHES_N_FUN(~, 0, ~)::value,
  62. BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, ~)
  63. >
  64. {};
  65. template<typename Expr, typename Tag, typename Args1, typename Args2>
  66. struct matches_< Expr, proto::basic_expr<Tag, Args1, N>, proto::basic_expr<proto::_, Args2, N> >
  67. : BOOST_PP_CAT(and_, N)<
  68. BOOST_PROTO_MATCHES_N_FUN(~, 0, ~)::value,
  69. BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, ~)
  70. >
  71. {};
  72. #endif
  73. #undef N
  74. #endif