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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/*==============================================================================
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_SCOPE_SCOPED_ENVIRONMENT_HPP
#define BOOST_PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP
#include <boost/phoenix/core/limits.hpp>
#include <boost/mpl/int.hpp>
#include <boost/fusion/sequence/sequence_facade.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/include/pop_front.hpp>
#include <boost/utility/result_of.hpp>
namespace boost { namespace phoenix
{
template<typename Env, typename OuterEnv, typename Locals, typename Map>
struct scoped_environment
: fusion::sequence_facade<
scoped_environment<Env, OuterEnv, Locals, Map>
, fusion::random_access_traversal_tag
>
{
typedef Env env_type;
typedef OuterEnv outer_env_type;
typedef Locals locals_type;
typedef Map map_type;
scoped_environment(
Env const & env
, OuterEnv const &outer_env
, Locals const &locals
)
: env(env)
, outer_env(outer_env)
, locals(locals)
{}
scoped_environment(scoped_environment const & o)
: env(o.env)
, outer_env(o.outer_env)
, locals(o.locals)
{};
Env const & env;
OuterEnv const & outer_env;
Locals const & locals;
typedef typename
fusion::result_of::pop_front<
typename add_const<
typename proto::detail::uncvref<Env>::type
>::type
>::type
args_type;
args_type args() const
{
return fusion::pop_front(env);
}
#define BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(INTRINSIC) \
template <typename Seq> \
struct INTRINSIC \
{ \
typedef \
typename fusion::result_of::INTRINSIC< \
typename mpl::eval_if_c< \
is_const< \
typename remove_reference< \
typename Seq::env_type \
>::type \
>::value \
, add_const< \
typename proto::detail::uncvref< \
typename Seq::env_type \
>::type \
> \
, proto::detail::uncvref< \
typename Seq::env_type \
> \
>::type \
>::type \
type; \
\
static type call(Seq & seq) \
{ \
return fusion::INTRINSIC(seq.env); \
} \
} \
/**/
BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(begin);
BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(end);
BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT(size);
#undef BOOST_PHOENIX_ADAPT_SCOPED_ENVIRONMENT
template <typename Seq, typename N>
struct value_at
{
typedef
typename fusion::result_of::value_at<
typename mpl::eval_if_c<
is_const<
typename remove_reference<
typename Seq::env_type
>::type
>::value
, add_const<
typename proto::detail::uncvref<
typename Seq::env_type
>::type
>
, proto::detail::uncvref<
typename Seq::env_type
>
>::type
, N
>::type
type;
};
template <typename Seq, typename N>
struct at
{
typedef
typename fusion::result_of::at<
typename mpl::eval_if_c<
is_const<
typename remove_reference<
typename Seq::env_type
>::type
>::value
, add_const<
typename proto::detail::uncvref<
typename Seq::env_type
>::type
>
, proto::detail::uncvref<
typename Seq::env_type
>
>::type
, N
>::type
type;
static type call(Seq & seq)
{
return fusion::at<N>(seq.env);
}
};
};
template <typename Env, typename Dummy = void>
struct is_scoped_environment : mpl::false_ {};
template <typename Env>
struct is_scoped_environment<Env&> : is_scoped_environment<Env> {};
template <typename Env, typename OuterEnv, typename Locals, typename Map>
struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> >
: mpl::true_
{};
template <typename Env, typename OuterEnv, typename Locals, typename Map>
struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> const>
: mpl::true_
{};
}}
#endif
|