1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
3 #include <boost/proto/transform/detail/preprocessed/when.hpp>
5 #elif !defined(BOOST_PP_IS_ITERATING)
7 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
8 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/when.hpp")
11 ///////////////////////////////////////////////////////////////////////////////
13 /// Definition of when transform.
15 // Copyright 2008 Eric Niebler. Distributed under the Boost
16 // Software License, Version 1.0. (See accompanying file
17 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
19 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
20 #pragma wave option(preserve: 1)
23 #define BOOST_PP_ITERATION_PARAMS_1 \
24 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/when.hpp>))
25 #include BOOST_PP_ITERATE()
27 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
28 #pragma wave option(output: null)
33 #define N BOOST_PP_ITERATION()
35 /// \brief A grammar element and a PrimitiveTransform that associates
36 /// a transform with the grammar.
38 /// Use <tt>when\<\></tt> to override a grammar's default transform
39 /// with a custom transform. It is for used when composing larger
40 /// transforms by associating smaller transforms with individual
41 /// rules in your grammar, as in the following transform which
42 /// counts the number of terminals in an expression.
45 /// // Count the terminals in an expression tree.
46 /// // Must be invoked with initial state == mpl::int_<0>().
47 /// struct CountLeaves
49 /// when<terminal<_>, mpl::next<_state>()>
50 /// , otherwise<fold<_, _state, CountLeaves> >
55 /// The <tt>when\<G, R(A0,A1,...)\></tt> form accepts either a
56 /// CallableTransform or an ObjectTransform as its second parameter.
57 /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::value</tt> to
58 /// distinguish between the two, and uses <tt>call\<\></tt> to
59 /// evaluate CallableTransforms and <tt>make\<\></tt> to evaluate
61 template<typename Grammar, typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
62 struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))>
63 : detail::when_impl<Grammar, R, R(BOOST_PP_ENUM_PARAMS(N, A))>
67 /// \brief A grammar element and a PrimitiveTransform that associates
68 /// a transform with the grammar.
70 /// Use <tt>when\<\></tt> to override a grammar's default transform
71 /// with a custom transform. It is for used when composing larger
72 /// transforms by associating smaller transforms with individual
73 /// rules in your grammar, as in the following transform which
74 /// counts the number of terminals in an expression.
77 /// // Count the terminals in an expression tree.
78 /// // Must be invoked with initial state == mpl::int_<0>().
79 /// struct CountLeaves
81 /// when<terminal<_>, mpl::next<_state>()>
82 /// , otherwise<fold<_, _state, CountLeaves> >
87 /// The <tt>when\<G, R(A0,A1,...)\></tt> form accepts either a
88 /// CallableTransform or an ObjectTransform as its second parameter.
89 /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::value</tt> to
90 /// distinguish between the two, and uses <tt>call\<\></tt> to
91 /// evaluate CallableTransforms and <tt>make\<\></tt> to evaluate
93 template<typename Grammar, typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
94 struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A)...)>
95 : detail::when_impl<Grammar, R, R(BOOST_PP_ENUM_PARAMS(N, A)...)>