Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2007 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7 #ifndef PHOENIX_OPERATOR_SELF_HPP
|
Chris@16
|
8 #define PHOENIX_OPERATOR_SELF_HPP
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/spirit/home/phoenix/core/composite.hpp>
|
Chris@16
|
11 #include <boost/spirit/home/phoenix/core/compose.hpp>
|
Chris@16
|
12 #include <boost/spirit/home/phoenix/detail/type_deduction.hpp>
|
Chris@16
|
13 #include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp>
|
Chris@16
|
14 #include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp>
|
Chris@16
|
15 #include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp>
|
Chris@16
|
16 #include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace phoenix
|
Chris@16
|
19 {
|
Chris@16
|
20 struct reference_eval;
|
Chris@16
|
21 struct dereference_eval;
|
Chris@16
|
22 struct assign_eval;
|
Chris@16
|
23 struct index_eval;
|
Chris@16
|
24
|
Chris@16
|
25 BOOST_UNARY_RESULT_OF(&x, result_of_reference)
|
Chris@16
|
26 BOOST_UNARY_RESULT_OF(*x, result_of_dereference)
|
Chris@16
|
27 BOOST_BINARY_RESULT_OF(x = y, result_of_assign)
|
Chris@16
|
28 BOOST_ASYMMETRIC_BINARY_RESULT_OF(x[y], result_of_index)
|
Chris@16
|
29
|
Chris@16
|
30 namespace detail
|
Chris@16
|
31 {
|
Chris@16
|
32 template <typename T0, typename T1>
|
Chris@16
|
33 struct make_assign_composite
|
Chris@16
|
34 {
|
Chris@16
|
35 typedef actor<typename as_composite<assign_eval, T0, T1>::type> type;
|
Chris@16
|
36 };
|
Chris@16
|
37
|
Chris@16
|
38 template <typename T0, typename T1>
|
Chris@16
|
39 struct make_index_composite
|
Chris@16
|
40 {
|
Chris@16
|
41 typedef actor<typename as_composite<index_eval, T0, T1>::type> type;
|
Chris@16
|
42 };
|
Chris@16
|
43 }
|
Chris@16
|
44
|
Chris@16
|
45 template <typename Base>
|
Chris@16
|
46 template <typename T1>
|
Chris@16
|
47 typename detail::make_assign_composite<actor<Base>, T1>::type
|
Chris@16
|
48 actor<Base>::operator=(T1 const& a1) const
|
Chris@16
|
49 {
|
Chris@16
|
50 return compose<assign_eval>(*this, a1);
|
Chris@16
|
51 }
|
Chris@16
|
52
|
Chris@16
|
53 template <typename Base>
|
Chris@16
|
54 template <typename T1>
|
Chris@16
|
55 typename detail::make_index_composite<actor<Base>, T1>::type
|
Chris@16
|
56 actor<Base>::operator[](T1 const& a1) const
|
Chris@16
|
57 {
|
Chris@16
|
58 return compose<index_eval>(*this, a1);
|
Chris@16
|
59 }
|
Chris@16
|
60
|
Chris@16
|
61 #define x a0.eval(env)
|
Chris@16
|
62 #define y a1.eval(env)
|
Chris@16
|
63
|
Chris@16
|
64 PHOENIX_UNARY_EVAL(reference_eval, result_of_reference, &x)
|
Chris@16
|
65 PHOENIX_UNARY_EVAL(dereference_eval, result_of_dereference, *x)
|
Chris@16
|
66 PHOENIX_UNARY_COMPOSE(reference_eval, &)
|
Chris@16
|
67 PHOENIX_UNARY_COMPOSE(dereference_eval, *)
|
Chris@16
|
68
|
Chris@16
|
69 PHOENIX_BINARY_EVAL(assign_eval, result_of_assign, x = y)
|
Chris@16
|
70 PHOENIX_BINARY_EVAL(index_eval, result_of_index, x[y])
|
Chris@16
|
71 }}
|
Chris@16
|
72
|
Chris@16
|
73 #undef x
|
Chris@16
|
74 #undef y
|
Chris@16
|
75 #endif
|