Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2007 Joel de Guzman
|
Chris@16
|
3 Copyright (c) 2004 Daniel Wallin
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8 #ifndef PHOENIX_SCOPE_LOCAL_VARIABLE_HPP
|
Chris@16
|
9 #define PHOENIX_SCOPE_LOCAL_VARIABLE_HPP
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/spirit/home/phoenix/core/limits.hpp>
|
Chris@16
|
12 #include <boost/spirit/home/phoenix/detail/local_reference.hpp>
|
Chris@16
|
13 #include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp>
|
Chris@16
|
14 #include <boost/spirit/home/phoenix/core/actor.hpp>
|
Chris@16
|
15 #include <boost/mpl/bool.hpp>
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost { namespace phoenix
|
Chris@16
|
18 {
|
Chris@16
|
19 template <typename Key>
|
Chris@16
|
20 struct local_variable
|
Chris@16
|
21 {
|
Chris@16
|
22 typedef Key key_type;
|
Chris@16
|
23
|
Chris@16
|
24 // This will prevent actor::operator()() from kicking in.
|
Chris@16
|
25 // Actually, we do not need all actor::operator()s for
|
Chris@16
|
26 // all arities, but this will suffice. The nullary
|
Chris@16
|
27 // actor::operator() is particularly troublesome because
|
Chris@16
|
28 // it is always eagerly evaluated by the compiler.
|
Chris@16
|
29 typedef mpl::true_ no_nullary;
|
Chris@16
|
30
|
Chris@16
|
31 template <typename Env>
|
Chris@16
|
32 struct result : detail::apply_local<local_variable<Key>, Env> {};
|
Chris@16
|
33
|
Chris@16
|
34 template <typename Env>
|
Chris@16
|
35 typename result<Env>::type
|
Chris@16
|
36 eval(Env const& env) const
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef typename result<Env>::type return_type;
|
Chris@16
|
39 typedef typename
|
Chris@16
|
40 detail::get_index<typename Env::map_type, Key>::type
|
Chris@16
|
41 index_type;
|
Chris@16
|
42 typedef detail::eval_local<Key> eval_local;
|
Chris@16
|
43
|
Chris@16
|
44 return eval_local::template get<return_type>(
|
Chris@16
|
45 env
|
Chris@16
|
46 , index_type());
|
Chris@16
|
47 }
|
Chris@16
|
48
|
Chris@16
|
49 private:
|
Chris@16
|
50 // silence MSVC warning C4512: assignment operator could not be generated
|
Chris@16
|
51 local_variable& operator= (local_variable const&);
|
Chris@16
|
52 };
|
Chris@16
|
53
|
Chris@16
|
54 namespace local_names
|
Chris@16
|
55 {
|
Chris@16
|
56 actor<local_variable<struct _a_key> > const _a
|
Chris@16
|
57 = local_variable<struct _a_key>();
|
Chris@16
|
58 actor<local_variable<struct _b_key> > const _b
|
Chris@16
|
59 = local_variable<struct _b_key>();
|
Chris@16
|
60 actor<local_variable<struct _c_key> > const _c
|
Chris@16
|
61 = local_variable<struct _c_key>();
|
Chris@16
|
62 actor<local_variable<struct _d_key> > const _d
|
Chris@16
|
63 = local_variable<struct _d_key>();
|
Chris@16
|
64 actor<local_variable<struct _e_key> > const _e
|
Chris@16
|
65 = local_variable<struct _e_key>();
|
Chris@16
|
66 actor<local_variable<struct _f_key> > const _f
|
Chris@16
|
67 = local_variable<struct _f_key>();
|
Chris@16
|
68 actor<local_variable<struct _g_key> > const _g
|
Chris@16
|
69 = local_variable<struct _g_key>();
|
Chris@16
|
70 actor<local_variable<struct _h_key> > const _h
|
Chris@16
|
71 = local_variable<struct _h_key>();
|
Chris@16
|
72 actor<local_variable<struct _i_key> > const _i
|
Chris@16
|
73 = local_variable<struct _i_key>();
|
Chris@16
|
74 actor<local_variable<struct _j_key> > const _j
|
Chris@16
|
75 = local_variable<struct _j_key>();
|
Chris@16
|
76 actor<local_variable<struct _k_key> > const _k
|
Chris@16
|
77 = local_variable<struct _k_key>();
|
Chris@16
|
78 actor<local_variable<struct _l_key> > const _l
|
Chris@16
|
79 = local_variable<struct _l_key>();
|
Chris@16
|
80 actor<local_variable<struct _m_key> > const _m
|
Chris@16
|
81 = local_variable<struct _m_key>();
|
Chris@16
|
82 actor<local_variable<struct _n_key> > const _n
|
Chris@16
|
83 = local_variable<struct _n_key>();
|
Chris@16
|
84 actor<local_variable<struct _o_key> > const _o
|
Chris@16
|
85 = local_variable<struct _o_key>();
|
Chris@16
|
86 actor<local_variable<struct _p_key> > const _p
|
Chris@16
|
87 = local_variable<struct _p_key>();
|
Chris@16
|
88 actor<local_variable<struct _q_key> > const _q
|
Chris@16
|
89 = local_variable<struct _q_key>();
|
Chris@16
|
90 actor<local_variable<struct _r_key> > const _r
|
Chris@16
|
91 = local_variable<struct _r_key>();
|
Chris@16
|
92 actor<local_variable<struct _s_key> > const _s
|
Chris@16
|
93 = local_variable<struct _s_key>();
|
Chris@16
|
94 actor<local_variable<struct _t_key> > const _t
|
Chris@16
|
95 = local_variable<struct _t_key>();
|
Chris@16
|
96 actor<local_variable<struct _u_key> > const _u
|
Chris@16
|
97 = local_variable<struct _u_key>();
|
Chris@16
|
98 actor<local_variable<struct _v_key> > const _v
|
Chris@16
|
99 = local_variable<struct _v_key>();
|
Chris@16
|
100 actor<local_variable<struct _w_key> > const _w
|
Chris@16
|
101 = local_variable<struct _w_key>();
|
Chris@16
|
102 actor<local_variable<struct _x_key> > const _x
|
Chris@16
|
103 = local_variable<struct _x_key>();
|
Chris@16
|
104 actor<local_variable<struct _y_key> > const _y
|
Chris@16
|
105 = local_variable<struct _y_key>();
|
Chris@16
|
106 actor<local_variable<struct _z_key> > const _z
|
Chris@16
|
107 = local_variable<struct _z_key>();
|
Chris@16
|
108 }
|
Chris@16
|
109 }}
|
Chris@16
|
110
|
Chris@16
|
111 #endif
|