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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
|
#if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
#include <boost/proto/detail/preprocessed/expr_variadic.hpp>
#else
#include <boost/proto/detail/preprocessed/expr.hpp>
#endif
#elif !defined(BOOST_PP_IS_ITERATING)
/// INTERNAL ONLY
///
#define BOOST_PROTO_CHILD(Z, N, DATA) \
typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(proto_child, N); \
BOOST_PP_CAT(proto_child, N) BOOST_PP_CAT(child, N); \
/**< INTERNAL ONLY */
/// INTERNAL ONLY
///
#define BOOST_PROTO_VOID(Z, N, DATA) \
typedef void BOOST_PP_CAT(proto_child, N); \
/**< INTERNAL ONLY */
// Generate variadic versions of expr
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr_variadic.hpp")
#endif
///////////////////////////////////////////////////////////////////////////////
/// \file expr_variadic.hpp
/// Contains definition of expr\<\> class template.
//
// Copyright 2008 Eric Niebler. 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)
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
#pragma wave option(preserve: 1)
#endif
// The expr<> specializations are actually defined here.
#define BOOST_PROTO_DEFINE_TERMINAL
#define BOOST_PP_ITERATION_PARAMS_1 \
(3, (0, 0, <boost/proto/detail/expr.hpp>))
#include BOOST_PP_ITERATE()
#undef BOOST_PROTO_DEFINE_TERMINAL
#define BOOST_PP_ITERATION_PARAMS_1 \
(3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/expr.hpp>))
#include BOOST_PP_ITERATE()
// Generate non-variadic versions of expr
#if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
#define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr.hpp")
///////////////////////////////////////////////////////////////////////////////
/// \file expr.hpp
/// Contains definition of expr\<\> class template.
//
// Copyright 2008 Eric Niebler. 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)
#pragma wave option(preserve: 1)
// The expr<> specializations are actually defined here.
#define BOOST_PROTO_DEFINE_TERMINAL
#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 0, <boost/proto/detail/expr.hpp>))
#include BOOST_PP_ITERATE()
#undef BOOST_PROTO_DEFINE_TERMINAL
#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/expr.hpp>))
#include BOOST_PP_ITERATE()
#pragma wave option(output: null)
#undef BOOST_NO_CXX11_VARIADIC_TEMPLATES
#endif
#undef BOOST_PROTO_CHILD
#undef BOOST_PROTO_VOID
#else
#define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
/// \brief Representation of a node in an expression tree.
///
/// \c proto::expr\<\> is a node in an expression template tree. It
/// is a container for its child sub-trees. It also serves as
/// the terminal nodes of the tree.
///
/// \c Tag is type that represents the operation encoded by
/// this expression. It is typically one of the structs
/// in the \c boost::proto::tag namespace, but it doesn't
/// have to be.
///
/// \c Args is a type list representing the type of the children
/// of this expression. It is an instantiation of one
/// of \c proto::list1\<\>, \c proto::list2\<\>, etc. The
/// child types must all themselves be either \c expr\<\>
/// or <tt>proto::expr\<\>&</tt>. If \c Args is an
/// instantiation of \c proto::term\<\> then this
/// \c expr\<\> type represents a terminal expression;
/// the parameter to the \c proto::term\<\> template
/// represents the terminal's value type.
///
/// \c Arity is an integral constant representing the number of child
/// nodes this node contains. If \c Arity is 0, then this
/// node is a terminal.
///
/// \c proto::expr\<\> is a valid Fusion random-access sequence, where
/// the elements of the sequence are the child expressions.
#ifdef BOOST_PROTO_DEFINE_TERMINAL
template<typename Tag, typename Arg0>
struct expr<Tag, term<Arg0>, 0>
#else
template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, typename Arg)>
struct expr<Tag, BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)>, BOOST_PP_ITERATION() >
#endif
{
typedef Tag proto_tag;
static const long proto_arity_c = BOOST_PP_ITERATION();
typedef mpl::long_<BOOST_PP_ITERATION() > proto_arity;
typedef expr proto_base_expr;
#ifdef BOOST_PROTO_DEFINE_TERMINAL
typedef term<Arg0> proto_args;
#else
typedef BOOST_PP_CAT(list, BOOST_PP_ITERATION())<BOOST_PP_ENUM_PARAMS(ARG_COUNT, Arg)> proto_args;
#endif
typedef basic_expr<Tag, proto_args, BOOST_PP_ITERATION() > proto_grammar;
typedef default_domain proto_domain;
typedef default_generator proto_generator;
typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag;
typedef expr proto_derived_expr;
typedef void proto_is_expr_; /**< INTERNAL ONLY */
BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD, ~)
BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
/// \return *this
///
BOOST_FORCEINLINE
expr const &proto_base() const
{
return *this;
}
/// \overload
///
BOOST_FORCEINLINE
expr &proto_base()
{
return *this;
}
#ifdef BOOST_PROTO_DEFINE_TERMINAL
/// \return A new \c expr\<\> object initialized with the specified
/// arguments.
///
template<typename A0>
BOOST_FORCEINLINE
static expr const make(A0 &a0)
{
return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
}
/// \overload
///
template<typename A0>
BOOST_FORCEINLINE
static expr const make(A0 const &a0)
{
return detail::make_terminal(a0, static_cast<expr *>(0), static_cast<proto_args *>(0));
}
#else
/// \return A new \c expr\<\> object initialized with the specified
/// arguments.
///
template<BOOST_PP_ENUM_PARAMS(ARG_COUNT, typename A)>
BOOST_FORCEINLINE
static expr const make(BOOST_PP_ENUM_BINARY_PARAMS(ARG_COUNT, A, const &a))
{
expr that = {BOOST_PP_ENUM_PARAMS(ARG_COUNT, a)};
return that;
}
#endif
#if 1 == BOOST_PP_ITERATION()
/// If \c Tag is \c boost::proto::tag::address_of and \c proto_child0 is
/// <tt>T&</tt>, then \c address_of_hack_type_ is <tt>T*</tt>.
/// Otherwise, it is some undefined type.
typedef typename detail::address_of_hack<Tag, proto_child0>::type address_of_hack_type_;
/// \return The address of <tt>this->child0</tt> if \c Tag is
/// \c boost::proto::tag::address_of. Otherwise, this function will
/// fail to compile.
///
/// \attention Proto overloads <tt>operator&</tt>, which means that
/// proto-ified objects cannot have their addresses taken, unless we use
/// the following hack to make \c &x implicitly convertible to \c X*.
BOOST_FORCEINLINE
operator address_of_hack_type_() const
{
return boost::addressof(this->child0);
}
#else
/// INTERNAL ONLY
///
typedef detail::not_a_valid_type address_of_hack_type_;
#endif
/// Assignment
///
/// \param a The rhs.
/// \return A new \c expr\<\> node representing an assignment of \c that to \c *this.
BOOST_FORCEINLINE
proto::expr<
proto::tag::assign
, list2<expr &, expr const &>
, 2
> const
operator =(expr const &a)
{
proto::expr<
proto::tag::assign
, list2<expr &, expr const &>
, 2
> that = {*this, a};
return that;
}
/// Assignment
///
/// \param a The rhs.
/// \return A new \c expr\<\> node representing an assignment of \c a to \c *this.
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::assign
, list2<expr const &, typename result_of::as_child<A>::type>
, 2
> const
operator =(A &a) const
{
proto::expr<
proto::tag::assign
, list2<expr const &, typename result_of::as_child<A>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
/// \overload
///
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::assign
, list2<expr const &, typename result_of::as_child<A const>::type>
, 2
> const
operator =(A const &a) const
{
proto::expr<
proto::tag::assign
, list2<expr const &, typename result_of::as_child<A const>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
#ifdef BOOST_PROTO_DEFINE_TERMINAL
/// \overload
///
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::assign
, list2<expr &, typename result_of::as_child<A>::type>
, 2
> const
operator =(A &a)
{
proto::expr<
proto::tag::assign
, list2<expr &, typename result_of::as_child<A>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
/// \overload
///
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::assign
, list2<expr &, typename result_of::as_child<A const>::type>
, 2
> const
operator =(A const &a)
{
proto::expr<
proto::tag::assign
, list2<expr &, typename result_of::as_child<A const>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
#endif
/// Subscript
///
/// \param a The rhs.
/// \return A new \c expr\<\> node representing \c *this subscripted with \c a.
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::subscript
, list2<expr const &, typename result_of::as_child<A>::type>
, 2
> const
operator [](A &a) const
{
proto::expr<
proto::tag::subscript
, list2<expr const &, typename result_of::as_child<A>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
/// \overload
///
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::subscript
, list2<expr const &, typename result_of::as_child<A const>::type>
, 2
> const
operator [](A const &a) const
{
proto::expr<
proto::tag::subscript
, list2<expr const &, typename result_of::as_child<A const>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
#ifdef BOOST_PROTO_DEFINE_TERMINAL
/// \overload
///
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::subscript
, list2<expr &, typename result_of::as_child<A>::type>
, 2
> const
operator [](A &a)
{
proto::expr<
proto::tag::subscript
, list2<expr &, typename result_of::as_child<A>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
/// \overload
///
template<typename A>
BOOST_FORCEINLINE
proto::expr<
proto::tag::subscript
, list2<expr &, typename result_of::as_child<A const>::type>
, 2
> const
operator [](A const &a)
{
proto::expr<
proto::tag::subscript
, list2<expr &, typename result_of::as_child<A const>::type>
, 2
> that = {*this, proto::as_child(a)};
return that;
}
#endif
/// Encodes the return type of \c expr\<\>::operator(), for use with \c boost::result_of\<\>
///
template<typename Sig>
struct result
{
typedef typename result_of::funop<Sig, expr, default_domain>::type const type;
};
#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
/// \overload
///
template<typename ...A>
BOOST_FORCEINLINE
typename result_of::funop<
expr const(A const &...)
, expr
, default_domain
>::type const
operator ()(A const &... a) const
{
return result_of::funop<
expr const(A const &...)
, expr
, default_domain
>::call(*this, a...);
}
#ifdef BOOST_PROTO_DEFINE_TERMINAL
/// \overload
///
template<typename ...A>
BOOST_FORCEINLINE
typename result_of::funop<
expr(A const &...)
, expr
, default_domain
>::type const
operator ()(A const &... a)
{
return result_of::funop<
expr(A const &...)
, expr
, default_domain
>::call(*this, a...);
}
#endif
#else // BOOST_NO_CXX11_VARIADIC_TEMPLATES
/// Function call
///
/// \return A new \c expr\<\> node representing the function invocation of \c (*this)().
BOOST_FORCEINLINE
proto::expr<proto::tag::function, list1<expr const &>, 1> const
operator ()() const
{
proto::expr<proto::tag::function, list1<expr const &>, 1> that = {*this};
return that;
}
#ifdef BOOST_PROTO_DEFINE_TERMINAL
/// \overload
///
BOOST_FORCEINLINE
proto::expr<proto::tag::function, list1<expr &>, 1> const
operator ()()
{
proto::expr<proto::tag::function, list1<expr &>, 1> that = {*this};
return that;
}
#endif
#define BOOST_PP_ITERATION_PARAMS_2 \
(3, (1, BOOST_PP_DEC(BOOST_PROTO_MAX_FUNCTION_CALL_ARITY), <boost/proto/detail/expr_funop.hpp>))
#include BOOST_PP_ITERATE()
#endif
};
#undef ARG_COUNT
#endif
|