Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file operators.hpp
|
Chris@16
|
3 /// Contains all the overloaded operators that make it possible to build
|
Chris@16
|
4 /// Proto expression trees.
|
Chris@16
|
5 //
|
Chris@16
|
6 // Copyright 2008 Eric Niebler. Distributed under the Boost
|
Chris@16
|
7 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9
|
Chris@16
|
10 #ifndef BOOST_PROTO_OPERATORS_HPP_EAN_04_01_2005
|
Chris@16
|
11 #define BOOST_PROTO_OPERATORS_HPP_EAN_04_01_2005
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/config.hpp>
|
Chris@16
|
14 #include <boost/preprocessor/punctuation/comma.hpp>
|
Chris@16
|
15 #include <boost/mpl/logical.hpp>
|
Chris@16
|
16 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
17 #include <boost/proto/proto_fwd.hpp>
|
Chris@16
|
18 #include <boost/proto/tags.hpp>
|
Chris@16
|
19 #include <boost/proto/domain.hpp>
|
Chris@16
|
20 #include <boost/proto/matches.hpp>
|
Chris@16
|
21 #include <boost/proto/generate.hpp>
|
Chris@16
|
22 #include <boost/proto/make_expr.hpp>
|
Chris@16
|
23
|
Chris@101
|
24 #if defined(_MSC_VER)
|
Chris@16
|
25 # pragma warning(push)
|
Chris@16
|
26 # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined
|
Chris@16
|
27 #endif
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost { namespace proto
|
Chris@16
|
30 {
|
Chris@16
|
31 namespace detail
|
Chris@16
|
32 {
|
Chris@16
|
33 template<typename MakeExpr, typename Grammar>
|
Chris@16
|
34 struct lazy_matches
|
Chris@16
|
35 : proto::matches<typename MakeExpr::type, Grammar>
|
Chris@16
|
36 {};
|
Chris@16
|
37
|
Chris@16
|
38 template<typename Domain, typename Grammar, typename Trait, typename Tag, typename Arg>
|
Chris@16
|
39 struct enable_unary
|
Chris@16
|
40 : boost::lazy_enable_if_c<
|
Chris@16
|
41 boost::mpl::and_<
|
Chris@16
|
42 Trait
|
Chris@16
|
43 , lazy_matches<result_of::make_expr<Tag, basic_default_domain, Arg>, Grammar>
|
Chris@16
|
44 >::value
|
Chris@16
|
45 , result_of::make_expr<Tag, Domain, Arg>
|
Chris@16
|
46 >
|
Chris@16
|
47 {};
|
Chris@16
|
48
|
Chris@16
|
49 template<typename Domain, typename Trait, typename Tag, typename Arg>
|
Chris@16
|
50 struct enable_unary<Domain, proto::_, Trait, Tag, Arg &>
|
Chris@16
|
51 : boost::lazy_enable_if_c<
|
Chris@16
|
52 Trait::value
|
Chris@16
|
53 , result_of::make_expr<Tag, Domain, Arg &>
|
Chris@16
|
54 >
|
Chris@16
|
55 {};
|
Chris@16
|
56
|
Chris@16
|
57 template<typename Trait, typename Tag, typename Arg>
|
Chris@16
|
58 struct enable_unary<deduce_domain, not_a_grammar, Trait, Tag, Arg &>
|
Chris@16
|
59 : enable_unary<
|
Chris@16
|
60 typename domain_of<Arg>::type
|
Chris@16
|
61 , typename domain_of<Arg>::type::proto_grammar
|
Chris@16
|
62 , Trait
|
Chris@16
|
63 , Tag
|
Chris@16
|
64 , Arg &
|
Chris@16
|
65 >
|
Chris@16
|
66 {};
|
Chris@16
|
67
|
Chris@16
|
68 template<typename Domain, typename Grammar, typename Trait, typename Tag, typename Left, typename Right>
|
Chris@16
|
69 struct enable_binary
|
Chris@16
|
70 : boost::lazy_enable_if_c<
|
Chris@16
|
71 boost::mpl::and_<
|
Chris@16
|
72 Trait
|
Chris@16
|
73 , lazy_matches<result_of::make_expr<Tag, basic_default_domain, Left, Right>, Grammar>
|
Chris@16
|
74 >::value
|
Chris@16
|
75 , result_of::make_expr<Tag, Domain, Left, Right>
|
Chris@16
|
76 >
|
Chris@16
|
77 {};
|
Chris@16
|
78
|
Chris@16
|
79 template<typename Domain, typename Trait, typename Tag, typename Left, typename Right>
|
Chris@16
|
80 struct enable_binary<Domain, proto::_, Trait, Tag, Left &, Right &>
|
Chris@16
|
81 : boost::lazy_enable_if_c<
|
Chris@16
|
82 Trait::value
|
Chris@16
|
83 , result_of::make_expr<Tag, Domain, Left &, Right &>
|
Chris@16
|
84 >
|
Chris@16
|
85 {};
|
Chris@16
|
86
|
Chris@16
|
87 template<typename Trait, typename Tag, typename Left, typename Right>
|
Chris@16
|
88 struct enable_binary<deduce_domain, not_a_grammar, Trait, Tag, Left &, Right &>
|
Chris@16
|
89 : enable_binary<
|
Chris@16
|
90 typename deduce_domain2<Left, Right>::type
|
Chris@16
|
91 , typename deduce_domain2<Left, Right>::type::proto_grammar
|
Chris@16
|
92 , Trait
|
Chris@16
|
93 , Tag
|
Chris@16
|
94 , Left &
|
Chris@16
|
95 , Right &
|
Chris@16
|
96 >
|
Chris@16
|
97 {};
|
Chris@16
|
98
|
Chris@16
|
99 } // detail
|
Chris@16
|
100
|
Chris@16
|
101 #define BOOST_PROTO_UNARY_OP_IS_POSTFIX_0
|
Chris@16
|
102 #define BOOST_PROTO_UNARY_OP_IS_POSTFIX_1 , int
|
Chris@16
|
103
|
Chris@16
|
104 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
Chris@16
|
105
|
Chris@16
|
106 #define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, TRAIT, DOMAIN, POST) \
|
Chris@16
|
107 template<typename Arg> \
|
Chris@16
|
108 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
109 typename boost::proto::detail::enable_unary< \
|
Chris@16
|
110 DOMAIN \
|
Chris@16
|
111 , DOMAIN::proto_grammar \
|
Chris@16
|
112 , BOOST_PROTO_APPLY_UNARY_(TRAIT, Arg) \
|
Chris@16
|
113 , TAG \
|
Chris@16
|
114 , Arg & \
|
Chris@16
|
115 >::type const \
|
Chris@16
|
116 operator OP(Arg &arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
|
Chris@16
|
117 { \
|
Chris@16
|
118 return boost::proto::detail::make_expr_<TAG, DOMAIN, Arg &>()(arg); \
|
Chris@16
|
119 } \
|
Chris@16
|
120 \
|
Chris@16
|
121 template<typename Arg> \
|
Chris@16
|
122 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
123 typename boost::proto::detail::enable_unary< \
|
Chris@16
|
124 DOMAIN \
|
Chris@16
|
125 , DOMAIN::proto_grammar \
|
Chris@16
|
126 , BOOST_PROTO_APPLY_UNARY_(TRAIT, Arg) \
|
Chris@16
|
127 , TAG \
|
Chris@16
|
128 , Arg const & \
|
Chris@16
|
129 >::type const \
|
Chris@16
|
130 operator OP(Arg const &arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
|
Chris@16
|
131 { \
|
Chris@16
|
132 return boost::proto::detail::make_expr_<TAG, DOMAIN, Arg const &>()(arg); \
|
Chris@16
|
133 } \
|
Chris@16
|
134 /**/
|
Chris@16
|
135
|
Chris@16
|
136 #define BOOST_PROTO_DEFINE_BINARY_OPERATOR(OP, TAG, TRAIT, DOMAIN) \
|
Chris@16
|
137 template<typename Left, typename Right> \
|
Chris@16
|
138 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
139 typename boost::proto::detail::enable_binary< \
|
Chris@16
|
140 DOMAIN \
|
Chris@16
|
141 , DOMAIN::proto_grammar \
|
Chris@16
|
142 , BOOST_PROTO_APPLY_BINARY_(TRAIT, Left, Right) \
|
Chris@16
|
143 , TAG \
|
Chris@16
|
144 , Left & \
|
Chris@16
|
145 , Right & \
|
Chris@16
|
146 >::type const \
|
Chris@16
|
147 operator OP(Left &left, Right &right) \
|
Chris@16
|
148 { \
|
Chris@16
|
149 return boost::proto::detail::make_expr_<TAG, DOMAIN, Left &, Right &>()(left, right); \
|
Chris@16
|
150 } \
|
Chris@16
|
151 \
|
Chris@16
|
152 template<typename Left, typename Right> \
|
Chris@16
|
153 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
154 typename boost::proto::detail::enable_binary< \
|
Chris@16
|
155 DOMAIN \
|
Chris@16
|
156 , DOMAIN::proto_grammar \
|
Chris@16
|
157 , BOOST_PROTO_APPLY_BINARY_(TRAIT, Left, Right) \
|
Chris@16
|
158 , TAG \
|
Chris@16
|
159 , Left & \
|
Chris@16
|
160 , Right const & \
|
Chris@16
|
161 >::type const \
|
Chris@16
|
162 operator OP(Left &left, Right const &right) \
|
Chris@16
|
163 { \
|
Chris@16
|
164 return boost::proto::detail::make_expr_<TAG, DOMAIN, Left &, Right const &>()(left, right); \
|
Chris@16
|
165 } \
|
Chris@16
|
166 \
|
Chris@16
|
167 template<typename Left, typename Right> \
|
Chris@16
|
168 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
169 typename boost::proto::detail::enable_binary< \
|
Chris@16
|
170 DOMAIN \
|
Chris@16
|
171 , DOMAIN::proto_grammar \
|
Chris@16
|
172 , BOOST_PROTO_APPLY_BINARY_(TRAIT, Left, Right) \
|
Chris@16
|
173 , TAG \
|
Chris@16
|
174 , Left const & \
|
Chris@16
|
175 , Right & \
|
Chris@16
|
176 >::type const \
|
Chris@16
|
177 operator OP(Left const &left, Right &right) \
|
Chris@16
|
178 { \
|
Chris@16
|
179 return boost::proto::detail::make_expr_<TAG, DOMAIN, Left const &, Right &>()(left, right); \
|
Chris@16
|
180 } \
|
Chris@16
|
181 \
|
Chris@16
|
182 template<typename Left, typename Right> \
|
Chris@16
|
183 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
184 typename boost::proto::detail::enable_binary< \
|
Chris@16
|
185 DOMAIN \
|
Chris@16
|
186 , DOMAIN::proto_grammar \
|
Chris@16
|
187 , BOOST_PROTO_APPLY_BINARY_(TRAIT, Left, Right) \
|
Chris@16
|
188 , TAG \
|
Chris@16
|
189 , Left const & \
|
Chris@16
|
190 , Right const & \
|
Chris@16
|
191 >::type const \
|
Chris@16
|
192 operator OP(Left const &left, Right const &right) \
|
Chris@16
|
193 { \
|
Chris@16
|
194 return boost::proto::detail::make_expr_<TAG, DOMAIN, Left const &, Right const &>()(left, right);\
|
Chris@16
|
195 } \
|
Chris@16
|
196 /**/
|
Chris@16
|
197
|
Chris@16
|
198 #else
|
Chris@16
|
199
|
Chris@16
|
200 #define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, TRAIT, DOMAIN, POST) \
|
Chris@16
|
201 template<typename Arg> \
|
Chris@16
|
202 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
203 typename boost::proto::detail::enable_unary< \
|
Chris@16
|
204 DOMAIN \
|
Chris@16
|
205 , DOMAIN::proto_grammar \
|
Chris@16
|
206 , BOOST_PROTO_APPLY_UNARY_(TRAIT, Arg) \
|
Chris@16
|
207 , TAG \
|
Chris@16
|
208 , Arg const & \
|
Chris@16
|
209 >::type const \
|
Chris@16
|
210 operator OP(Arg &&arg BOOST_PROTO_UNARY_OP_IS_POSTFIX_ ## POST) \
|
Chris@16
|
211 { \
|
Chris@16
|
212 return boost::proto::detail::make_expr_<TAG, DOMAIN, Arg const &>()(arg); \
|
Chris@16
|
213 } \
|
Chris@16
|
214 /**/
|
Chris@16
|
215
|
Chris@16
|
216 #define BOOST_PROTO_DEFINE_BINARY_OPERATOR(OP, TAG, TRAIT, DOMAIN) \
|
Chris@16
|
217 template<typename Left, typename Right> \
|
Chris@16
|
218 BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \
|
Chris@16
|
219 typename boost::proto::detail::enable_binary< \
|
Chris@16
|
220 DOMAIN \
|
Chris@16
|
221 , DOMAIN::proto_grammar \
|
Chris@16
|
222 , BOOST_PROTO_APPLY_BINARY_(TRAIT, Left, Right) \
|
Chris@16
|
223 , TAG \
|
Chris@16
|
224 , Left const & \
|
Chris@16
|
225 , Right const & \
|
Chris@16
|
226 >::type const \
|
Chris@16
|
227 operator OP(Left &&left, Right &&right) \
|
Chris@16
|
228 { \
|
Chris@16
|
229 return boost::proto::detail::make_expr_<TAG, DOMAIN, Left const &, Right const &>()(left, right);\
|
Chris@16
|
230 } \
|
Chris@16
|
231 /**/
|
Chris@16
|
232
|
Chris@16
|
233 #endif
|
Chris@16
|
234
|
Chris@16
|
235 #define BOOST_PROTO_DEFINE_OPERATORS(TRAIT, DOMAIN) \
|
Chris@16
|
236 BOOST_PROTO_DEFINE_UNARY_OPERATOR(+, boost::proto::tag::unary_plus, TRAIT, DOMAIN, 0) \
|
Chris@16
|
237 BOOST_PROTO_DEFINE_UNARY_OPERATOR(-, boost::proto::tag::negate, TRAIT, DOMAIN, 0) \
|
Chris@16
|
238 BOOST_PROTO_DEFINE_UNARY_OPERATOR(*, boost::proto::tag::dereference, TRAIT, DOMAIN, 0) \
|
Chris@16
|
239 BOOST_PROTO_DEFINE_UNARY_OPERATOR(~, boost::proto::tag::complement, TRAIT, DOMAIN, 0) \
|
Chris@16
|
240 BOOST_PROTO_DEFINE_UNARY_OPERATOR(&, boost::proto::tag::address_of, TRAIT, DOMAIN, 0) \
|
Chris@16
|
241 BOOST_PROTO_DEFINE_UNARY_OPERATOR(!, boost::proto::tag::logical_not, TRAIT, DOMAIN, 0) \
|
Chris@16
|
242 BOOST_PROTO_DEFINE_UNARY_OPERATOR(++, boost::proto::tag::pre_inc, TRAIT, DOMAIN, 0) \
|
Chris@16
|
243 BOOST_PROTO_DEFINE_UNARY_OPERATOR(--, boost::proto::tag::pre_dec, TRAIT, DOMAIN, 0) \
|
Chris@16
|
244 BOOST_PROTO_DEFINE_UNARY_OPERATOR(++, boost::proto::tag::post_inc, TRAIT, DOMAIN, 1) \
|
Chris@16
|
245 BOOST_PROTO_DEFINE_UNARY_OPERATOR(--, boost::proto::tag::post_dec, TRAIT, DOMAIN, 1) \
|
Chris@16
|
246 BOOST_PROTO_DEFINE_BINARY_OPERATOR(<<, boost::proto::tag::shift_left, TRAIT, DOMAIN) \
|
Chris@16
|
247 BOOST_PROTO_DEFINE_BINARY_OPERATOR(>>, boost::proto::tag::shift_right, TRAIT, DOMAIN) \
|
Chris@16
|
248 BOOST_PROTO_DEFINE_BINARY_OPERATOR(*, boost::proto::tag::multiplies, TRAIT, DOMAIN) \
|
Chris@16
|
249 BOOST_PROTO_DEFINE_BINARY_OPERATOR(/, boost::proto::tag::divides, TRAIT, DOMAIN) \
|
Chris@16
|
250 BOOST_PROTO_DEFINE_BINARY_OPERATOR(%, boost::proto::tag::modulus, TRAIT, DOMAIN) \
|
Chris@16
|
251 BOOST_PROTO_DEFINE_BINARY_OPERATOR(+, boost::proto::tag::plus, TRAIT, DOMAIN) \
|
Chris@16
|
252 BOOST_PROTO_DEFINE_BINARY_OPERATOR(-, boost::proto::tag::minus, TRAIT, DOMAIN) \
|
Chris@16
|
253 BOOST_PROTO_DEFINE_BINARY_OPERATOR(<, boost::proto::tag::less, TRAIT, DOMAIN) \
|
Chris@16
|
254 BOOST_PROTO_DEFINE_BINARY_OPERATOR(>, boost::proto::tag::greater, TRAIT, DOMAIN) \
|
Chris@16
|
255 BOOST_PROTO_DEFINE_BINARY_OPERATOR(<=, boost::proto::tag::less_equal, TRAIT, DOMAIN) \
|
Chris@16
|
256 BOOST_PROTO_DEFINE_BINARY_OPERATOR(>=, boost::proto::tag::greater_equal, TRAIT, DOMAIN) \
|
Chris@16
|
257 BOOST_PROTO_DEFINE_BINARY_OPERATOR(==, boost::proto::tag::equal_to, TRAIT, DOMAIN) \
|
Chris@16
|
258 BOOST_PROTO_DEFINE_BINARY_OPERATOR(!=, boost::proto::tag::not_equal_to, TRAIT, DOMAIN) \
|
Chris@16
|
259 BOOST_PROTO_DEFINE_BINARY_OPERATOR(||, boost::proto::tag::logical_or, TRAIT, DOMAIN) \
|
Chris@16
|
260 BOOST_PROTO_DEFINE_BINARY_OPERATOR(&&, boost::proto::tag::logical_and, TRAIT, DOMAIN) \
|
Chris@16
|
261 BOOST_PROTO_DEFINE_BINARY_OPERATOR(&, boost::proto::tag::bitwise_and, TRAIT, DOMAIN) \
|
Chris@16
|
262 BOOST_PROTO_DEFINE_BINARY_OPERATOR(|, boost::proto::tag::bitwise_or, TRAIT, DOMAIN) \
|
Chris@16
|
263 BOOST_PROTO_DEFINE_BINARY_OPERATOR(^, boost::proto::tag::bitwise_xor, TRAIT, DOMAIN) \
|
Chris@16
|
264 BOOST_PROTO_DEFINE_BINARY_OPERATOR(BOOST_PP_COMMA(), boost::proto::tag::comma, TRAIT, DOMAIN) \
|
Chris@16
|
265 BOOST_PROTO_DEFINE_BINARY_OPERATOR(->*, boost::proto::tag::mem_ptr, TRAIT, DOMAIN) \
|
Chris@16
|
266 BOOST_PROTO_DEFINE_BINARY_OPERATOR(<<=, boost::proto::tag::shift_left_assign, TRAIT, DOMAIN) \
|
Chris@16
|
267 BOOST_PROTO_DEFINE_BINARY_OPERATOR(>>=, boost::proto::tag::shift_right_assign, TRAIT, DOMAIN) \
|
Chris@16
|
268 BOOST_PROTO_DEFINE_BINARY_OPERATOR(*=, boost::proto::tag::multiplies_assign, TRAIT, DOMAIN) \
|
Chris@16
|
269 BOOST_PROTO_DEFINE_BINARY_OPERATOR(/=, boost::proto::tag::divides_assign, TRAIT, DOMAIN) \
|
Chris@16
|
270 BOOST_PROTO_DEFINE_BINARY_OPERATOR(%=, boost::proto::tag::modulus_assign, TRAIT, DOMAIN) \
|
Chris@16
|
271 BOOST_PROTO_DEFINE_BINARY_OPERATOR(+=, boost::proto::tag::plus_assign, TRAIT, DOMAIN) \
|
Chris@16
|
272 BOOST_PROTO_DEFINE_BINARY_OPERATOR(-=, boost::proto::tag::minus_assign, TRAIT, DOMAIN) \
|
Chris@16
|
273 BOOST_PROTO_DEFINE_BINARY_OPERATOR(&=, boost::proto::tag::bitwise_and_assign, TRAIT, DOMAIN) \
|
Chris@16
|
274 BOOST_PROTO_DEFINE_BINARY_OPERATOR(|=, boost::proto::tag::bitwise_or_assign, TRAIT, DOMAIN) \
|
Chris@16
|
275 BOOST_PROTO_DEFINE_BINARY_OPERATOR(^=, boost::proto::tag::bitwise_xor_assign, TRAIT, DOMAIN) \
|
Chris@16
|
276 /**/
|
Chris@16
|
277
|
Chris@16
|
278 // Extensions are a superset of Proto expressions
|
Chris@16
|
279 template<typename T>
|
Chris@16
|
280 struct is_extension
|
Chris@16
|
281 : is_expr<T>
|
Chris@16
|
282 {};
|
Chris@16
|
283
|
Chris@16
|
284 template<typename T>
|
Chris@16
|
285 struct is_extension<T &>
|
Chris@16
|
286 : is_expr<T>
|
Chris@16
|
287 {};
|
Chris@16
|
288
|
Chris@16
|
289 #define BOOST_PROTO_APPLY_UNARY_(TRAIT, ARG) TRAIT<ARG>
|
Chris@16
|
290 #define BOOST_PROTO_APPLY_BINARY_(TRAIT, LEFT, RIGHT) boost::mpl::or_<TRAIT<LEFT>, TRAIT<RIGHT> >
|
Chris@16
|
291
|
Chris@16
|
292 namespace exprns_
|
Chris@16
|
293 {
|
Chris@16
|
294 // This defines all of Proto's built-in free operator overloads
|
Chris@16
|
295 BOOST_PROTO_DEFINE_OPERATORS(is_extension, deduce_domain)
|
Chris@16
|
296
|
Chris@16
|
297 // if_else, for the non-overloadable ternary conditional operator ?:
|
Chris@16
|
298 template<typename A0, typename A1, typename A2>
|
Chris@16
|
299 BOOST_FORCEINLINE
|
Chris@16
|
300 typename result_of::make_expr<
|
Chris@16
|
301 tag::if_else_
|
Chris@16
|
302 , deduce_domain
|
Chris@16
|
303 , A0 const &
|
Chris@16
|
304 , A1 const &
|
Chris@16
|
305 , A2 const &
|
Chris@16
|
306 >::type const
|
Chris@16
|
307 if_else(A0 const &a0, A1 const &a1, A2 const &a2)
|
Chris@16
|
308 {
|
Chris@16
|
309 return proto::detail::make_expr_<
|
Chris@16
|
310 tag::if_else_
|
Chris@16
|
311 , deduce_domain
|
Chris@16
|
312 , A0 const &
|
Chris@16
|
313 , A1 const &
|
Chris@16
|
314 , A2 const &
|
Chris@16
|
315 >()(a0, a1, a2);
|
Chris@16
|
316 }
|
Chris@16
|
317 }
|
Chris@16
|
318
|
Chris@16
|
319 using exprns_::if_else;
|
Chris@16
|
320
|
Chris@16
|
321 #undef BOOST_PROTO_APPLY_UNARY_
|
Chris@16
|
322 #undef BOOST_PROTO_APPLY_BINARY_
|
Chris@16
|
323
|
Chris@16
|
324 // Redefine BOOST_PROTO_APPLY_UNARY_ and BOOST_PROTO_APPLY_BINARY_ so that end users
|
Chris@16
|
325 // can use BOOST_PROTO_DEFINE_OPERATORS to define Proto operator overloads that work
|
Chris@16
|
326 // with their own terminal types.
|
Chris@16
|
327
|
Chris@16
|
328 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
Chris@16
|
329
|
Chris@16
|
330 #define BOOST_PROTO_APPLY_UNARY_(TRAIT, ARG) \
|
Chris@16
|
331 boost::mpl::and_< \
|
Chris@16
|
332 TRAIT<ARG> \
|
Chris@16
|
333 , boost::mpl::not_<boost::proto::is_extension<ARG> > \
|
Chris@16
|
334 > \
|
Chris@16
|
335 /**/
|
Chris@16
|
336
|
Chris@16
|
337 #define BOOST_PROTO_APPLY_BINARY_(TRAIT, LEFT, RIGHT) \
|
Chris@16
|
338 boost::mpl::and_< \
|
Chris@16
|
339 boost::mpl::or_<TRAIT<LEFT>, TRAIT<RIGHT> > \
|
Chris@16
|
340 , boost::mpl::not_< \
|
Chris@16
|
341 boost::mpl::or_< \
|
Chris@16
|
342 boost::proto::is_extension<LEFT> \
|
Chris@16
|
343 , boost::proto::is_extension<RIGHT> \
|
Chris@16
|
344 > \
|
Chris@16
|
345 > \
|
Chris@16
|
346 > \
|
Chris@16
|
347 /**/
|
Chris@16
|
348
|
Chris@16
|
349 #else
|
Chris@16
|
350
|
Chris@16
|
351 #define BOOST_PROTO_APPLY_UNARY_(TRAIT, ARG) \
|
Chris@16
|
352 boost::mpl::and_< \
|
Chris@16
|
353 TRAIT<BOOST_PROTO_UNCVREF(ARG) > \
|
Chris@16
|
354 , boost::mpl::not_<boost::proto::is_extension<ARG> > \
|
Chris@16
|
355 > \
|
Chris@16
|
356 /**/
|
Chris@16
|
357
|
Chris@16
|
358 #define BOOST_PROTO_APPLY_BINARY_(TRAIT, LEFT, RIGHT) \
|
Chris@16
|
359 boost::mpl::and_< \
|
Chris@16
|
360 boost::mpl::or_<TRAIT<BOOST_PROTO_UNCVREF(LEFT) >, TRAIT<BOOST_PROTO_UNCVREF(RIGHT) > > \
|
Chris@16
|
361 , boost::mpl::not_< \
|
Chris@16
|
362 boost::mpl::or_< \
|
Chris@16
|
363 boost::proto::is_extension<LEFT> \
|
Chris@16
|
364 , boost::proto::is_extension<RIGHT> \
|
Chris@16
|
365 > \
|
Chris@16
|
366 > \
|
Chris@16
|
367 > \
|
Chris@16
|
368 /**/
|
Chris@16
|
369
|
Chris@16
|
370 #endif
|
Chris@16
|
371
|
Chris@16
|
372 }}
|
Chris@16
|
373
|
Chris@101
|
374 #if defined(_MSC_VER)
|
Chris@16
|
375 # pragma warning(pop)
|
Chris@16
|
376 #endif
|
Chris@16
|
377
|
Chris@16
|
378 #endif
|