File indexing completed on 2025-01-18 09:46:04
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_PHOENIX_DEFINE_OPERATOR_HPP
0010 #define BOOST_PHOENIX_DEFINE_OPERATOR_HPP
0011
0012 #include <boost/phoenix/core/meta_grammar.hpp>
0013 #include <boost/preprocessor/seq/for_each.hpp>
0014
0015 #define BOOST_PHOENIX_UNARY_EXPRESSION(__, ___, name) \
0016 template <typename Operand> \
0017 struct name \
0018 : expr<proto::tag::name, Operand> \
0019 {}; \
0020
0021
0022 #define BOOST_PHOENIX_UNARY_RULE(__, ___, name) \
0023 struct name \
0024 : expression::name<meta_grammar> \
0025 {}; \
0026
0027
0028 #define BOOST_PHOENIX_UNARY_FUNCTIONAL(__, ___, name) \
0029 namespace functional \
0030 { \
0031 typedef \
0032 proto::functional::make_expr<proto::tag::name> \
0033 BOOST_PP_CAT(make_, name); \
0034 } \
0035 namespace result_of \
0036 { \
0037 template <typename Operand> \
0038 struct BOOST_PP_CAT(make_, name) \
0039 : boost::result_of< \
0040 functional:: BOOST_PP_CAT(make_, name)( \
0041 Operand \
0042 ) \
0043 > \
0044 {}; \
0045 } \
0046 template <typename Operand> \
0047 inline \
0048 typename result_of::BOOST_PP_CAT(make_, name)<Operand>::type \
0049 BOOST_PP_CAT(make_, name)(Operand const & operand) \
0050 { \
0051 return functional::BOOST_PP_CAT(make_, name)()(operand); \
0052 } \
0053
0054
0055 #define BOOST_PHOENIX_BINARY_EXPRESSION(__, ___, name) \
0056 template <typename Lhs, typename Rhs> \
0057 struct name \
0058 : expr<proto::tag::name, Lhs, Rhs> \
0059 {}; \
0060
0061
0062 #define BOOST_PHOENIX_BINARY_RULE(__, ___, name) \
0063 struct name \
0064 : expression::name<meta_grammar, meta_grammar> \
0065 {}; \
0066
0067
0068 #define BOOST_PHOENIX_BINARY_FUNCTIONAL(__, ___, name) \
0069 namespace functional \
0070 { \
0071 typedef \
0072 proto::functional::make_expr<proto::tag::name> \
0073 BOOST_PP_CAT(make_, name); \
0074 } \
0075 namespace result_of \
0076 { \
0077 template <typename Lhs, typename Rhs> \
0078 struct BOOST_PP_CAT(make_, name) \
0079 : boost::result_of< \
0080 functional:: BOOST_PP_CAT(make_, name)( \
0081 Lhs, Rhs \
0082 ) \
0083 > \
0084 {}; \
0085 } \
0086 template <typename Rhs, typename Lhs> \
0087 inline \
0088 typename result_of::BOOST_PP_CAT(make_, name)<Rhs, Lhs>::type \
0089 BOOST_PP_CAT(make_, name)(Lhs const & lhs, Rhs const & rhs) \
0090 { \
0091 return functional::BOOST_PP_CAT(make_, name)()(lhs, rhs); \
0092 } \
0093
0094
0095 #define BOOST_PHOENIX_GRAMMAR(_, __, name) \
0096 template <typename Dummy> \
0097 struct meta_grammar::case_<proto::tag::name, Dummy> \
0098 : enable_rule<rule::name, Dummy> \
0099 {}; \
0100
0101
0102 #define BOOST_PHOENIX_UNARY_OPERATORS(ops) \
0103 namespace expression { \
0104 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_EXPRESSION, _, ops) \
0105 } \
0106 namespace rule { \
0107 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_RULE, _, ops) \
0108 } \
0109 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_GRAMMAR, _, ops) \
0110 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_FUNCTIONAL, _, ops) \
0111
0112
0113
0114 #define BOOST_PHOENIX_BINARY_OPERATORS(ops) \
0115 namespace expression { \
0116 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_EXPRESSION, _, ops) \
0117 } \
0118 namespace rule { \
0119 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_RULE, _, ops) \
0120 } \
0121 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_GRAMMAR, _, ops) \
0122 BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_FUNCTIONAL, _, ops) \
0123
0124
0125 #endif