1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*==============================================================================
Copyright (c) 2005-2010 Joel de Guzman
Copyright (c) 2010 Thomas Heller
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#ifndef BOOST_PHOENIX_DEFINE_OPERATOR_HPP
#define BOOST_PHOENIX_DEFINE_OPERATOR_HPP
#include <boost/phoenix/core/meta_grammar.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#define BOOST_PHOENIX_UNARY_EXPRESSION(__, ___, name) \
template <typename Operand> \
struct name \
: expr<proto::tag::name, Operand> \
{}; \
/**/
#define BOOST_PHOENIX_UNARY_RULE(__, ___, name) \
struct name \
: expression::name<meta_grammar> \
{}; \
/**/
#define BOOST_PHOENIX_UNARY_FUNCTIONAL(__, ___, name) \
namespace functional \
{ \
typedef \
proto::functional::make_expr<proto::tag::name> \
BOOST_PP_CAT(make_, name); \
} \
namespace result_of \
{ \
template <typename Operand> \
struct BOOST_PP_CAT(make_, name) \
: boost::result_of< \
functional:: BOOST_PP_CAT(make_, name)( \
Operand \
) \
> \
{}; \
} \
template <typename Operand> \
typename result_of::BOOST_PP_CAT(make_, name)<Operand>::type \
inline BOOST_PP_CAT(make_, name)(Operand const & operand) \
{ \
return functional::BOOST_PP_CAT(make_, name)()(operand); \
} \
/**/
#define BOOST_PHOENIX_BINARY_EXPRESSION(__, ___, name) \
template <typename Lhs, typename Rhs> \
struct name \
: expr<proto::tag::name, Lhs, Rhs> \
{}; \
/**/
#define BOOST_PHOENIX_BINARY_RULE(__, ___, name) \
struct name \
: expression::name<meta_grammar, meta_grammar> \
{}; \
/**/
#define BOOST_PHOENIX_BINARY_FUNCTIONAL(__, ___, name) \
namespace functional \
{ \
typedef \
proto::functional::make_expr<proto::tag::name> \
BOOST_PP_CAT(make_, name); \
} \
namespace result_of \
{ \
template <typename Lhs, typename Rhs> \
struct BOOST_PP_CAT(make_, name) \
: boost::result_of< \
functional:: BOOST_PP_CAT(make_, name)( \
Lhs, Rhs \
) \
> \
{}; \
} \
template <typename Rhs, typename Lhs> \
typename result_of::BOOST_PP_CAT(make_, name)<Rhs, Lhs>::type \
inline BOOST_PP_CAT(make_, name)(Lhs const & lhs, Rhs const & rhs) \
{ \
return functional::BOOST_PP_CAT(make_, name)()(lhs, rhs); \
} \
/**/
#define BOOST_PHOENIX_GRAMMAR(_, __, name) \
template <typename Dummy> \
struct meta_grammar::case_<proto::tag::name, Dummy> \
: enable_rule<rule::name, Dummy> \
{}; \
/**/
#define BOOST_PHOENIX_UNARY_OPERATORS(ops) \
namespace expression { \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_EXPRESSION, _, ops) \
} \
namespace rule { \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_RULE, _, ops) \
} \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_GRAMMAR, _, ops) \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_UNARY_FUNCTIONAL, _, ops) \
/**/
#define BOOST_PHOENIX_BINARY_OPERATORS(ops) \
namespace expression { \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_EXPRESSION, _, ops) \
} \
namespace rule { \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_RULE, _, ops) \
} \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_GRAMMAR, _, ops) \
BOOST_PP_SEQ_FOR_EACH(BOOST_PHOENIX_BINARY_FUNCTIONAL, _, ops) \
/**/
#endif
|