Chris@16
|
1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
|
Chris@16
|
2
|
Chris@16
|
3 #include <boost/proto/transform/detail/preprocessed/when.hpp>
|
Chris@16
|
4
|
Chris@16
|
5 #elif !defined(BOOST_PP_IS_ITERATING)
|
Chris@16
|
6
|
Chris@16
|
7 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
Chris@16
|
8 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/when.hpp")
|
Chris@16
|
9 #endif
|
Chris@16
|
10
|
Chris@16
|
11 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
12 /// \file when.hpp
|
Chris@16
|
13 /// Definition of when transform.
|
Chris@16
|
14 //
|
Chris@16
|
15 // Copyright 2008 Eric Niebler. Distributed under the Boost
|
Chris@16
|
16 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
17 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
18
|
Chris@16
|
19 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
Chris@16
|
20 #pragma wave option(preserve: 1)
|
Chris@16
|
21 #endif
|
Chris@16
|
22
|
Chris@16
|
23 #define BOOST_PP_ITERATION_PARAMS_1 \
|
Chris@16
|
24 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/when.hpp>))
|
Chris@16
|
25 #include BOOST_PP_ITERATE()
|
Chris@16
|
26
|
Chris@16
|
27 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
|
Chris@16
|
28 #pragma wave option(output: null)
|
Chris@16
|
29 #endif
|
Chris@16
|
30
|
Chris@16
|
31 #else
|
Chris@16
|
32
|
Chris@16
|
33 #define N BOOST_PP_ITERATION()
|
Chris@16
|
34
|
Chris@16
|
35 /// \brief A grammar element and a PrimitiveTransform that associates
|
Chris@16
|
36 /// a transform with the grammar.
|
Chris@16
|
37 ///
|
Chris@16
|
38 /// Use <tt>when\<\></tt> to override a grammar's default transform
|
Chris@16
|
39 /// with a custom transform. It is for used when composing larger
|
Chris@16
|
40 /// transforms by associating smaller transforms with individual
|
Chris@16
|
41 /// rules in your grammar, as in the following transform which
|
Chris@16
|
42 /// counts the number of terminals in an expression.
|
Chris@16
|
43 ///
|
Chris@16
|
44 /// \code
|
Chris@16
|
45 /// // Count the terminals in an expression tree.
|
Chris@16
|
46 /// // Must be invoked with initial state == mpl::int_<0>().
|
Chris@16
|
47 /// struct CountLeaves
|
Chris@16
|
48 /// : or_<
|
Chris@16
|
49 /// when<terminal<_>, mpl::next<_state>()>
|
Chris@16
|
50 /// , otherwise<fold<_, _state, CountLeaves> >
|
Chris@16
|
51 /// >
|
Chris@16
|
52 /// {};
|
Chris@16
|
53 /// \endcode
|
Chris@16
|
54 ///
|
Chris@16
|
55 /// The <tt>when\<G, R(A0,A1,...)\></tt> form accepts either a
|
Chris@16
|
56 /// CallableTransform or an ObjectTransform as its second parameter.
|
Chris@16
|
57 /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::value</tt> to
|
Chris@16
|
58 /// distinguish between the two, and uses <tt>call\<\></tt> to
|
Chris@16
|
59 /// evaluate CallableTransforms and <tt>make\<\></tt> to evaluate
|
Chris@16
|
60 /// ObjectTransforms.
|
Chris@16
|
61 template<typename Grammar, typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
|
Chris@16
|
62 struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))>
|
Chris@16
|
63 : detail::when_impl<Grammar, R, R(BOOST_PP_ENUM_PARAMS(N, A))>
|
Chris@16
|
64 {};
|
Chris@16
|
65
|
Chris@16
|
66 #if N > 0
|
Chris@16
|
67 /// \brief A grammar element and a PrimitiveTransform that associates
|
Chris@16
|
68 /// a transform with the grammar.
|
Chris@16
|
69 ///
|
Chris@16
|
70 /// Use <tt>when\<\></tt> to override a grammar's default transform
|
Chris@16
|
71 /// with a custom transform. It is for used when composing larger
|
Chris@16
|
72 /// transforms by associating smaller transforms with individual
|
Chris@16
|
73 /// rules in your grammar, as in the following transform which
|
Chris@16
|
74 /// counts the number of terminals in an expression.
|
Chris@16
|
75 ///
|
Chris@16
|
76 /// \code
|
Chris@16
|
77 /// // Count the terminals in an expression tree.
|
Chris@16
|
78 /// // Must be invoked with initial state == mpl::int_<0>().
|
Chris@16
|
79 /// struct CountLeaves
|
Chris@16
|
80 /// : or_<
|
Chris@16
|
81 /// when<terminal<_>, mpl::next<_state>()>
|
Chris@16
|
82 /// , otherwise<fold<_, _state, CountLeaves> >
|
Chris@16
|
83 /// >
|
Chris@16
|
84 /// {};
|
Chris@16
|
85 /// \endcode
|
Chris@16
|
86 ///
|
Chris@16
|
87 /// The <tt>when\<G, R(A0,A1,...)\></tt> form accepts either a
|
Chris@16
|
88 /// CallableTransform or an ObjectTransform as its second parameter.
|
Chris@16
|
89 /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::value</tt> to
|
Chris@16
|
90 /// distinguish between the two, and uses <tt>call\<\></tt> to
|
Chris@16
|
91 /// evaluate CallableTransforms and <tt>make\<\></tt> to evaluate
|
Chris@16
|
92 /// ObjectTransforms.
|
Chris@16
|
93 template<typename Grammar, typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
|
Chris@16
|
94 struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A)...)>
|
Chris@16
|
95 : detail::when_impl<Grammar, R, R(BOOST_PP_ENUM_PARAMS(N, A)...)>
|
Chris@16
|
96 {};
|
Chris@16
|
97 #endif
|
Chris@16
|
98
|
Chris@16
|
99 #undef N
|
Chris@16
|
100
|
Chris@16
|
101 #endif
|