1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
2 
3     #include <boost/proto/transform/detail/preprocessed/when.hpp>
4 
5 #elif !defined(BOOST_PP_IS_ITERATING)
6 
7     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
8         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/when.hpp")
9     #endif
10 
11     ///////////////////////////////////////////////////////////////////////////////
12     /// \file when.hpp
13     /// Definition of when transform.
14     //
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)
18 
19     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
20         #pragma wave option(preserve: 1)
21     #endif
22 
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()
26 
27     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
28         #pragma wave option(output: null)
29     #endif
30 
31 #else
32 
33     #define N BOOST_PP_ITERATION()
34 
35     /// \brief A grammar element and a PrimitiveTransform that associates
36     /// a transform with the grammar.
37     ///
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.
43     ///
44     /// \code
45     /// // Count the terminals in an expression tree.
46     /// // Must be invoked with initial state == mpl::int_<0>().
47     /// struct CountLeaves
48     ///   : or_<
49     ///         when<terminal<_>, mpl::next<_state>()>
50     ///       , otherwise<fold<_, _state, CountLeaves> >
51     ///     >
52     /// {};
53     /// \endcode
54     ///
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
60     /// ObjectTransforms.
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))>
64     {};
65 
66     #if N > 0
67     /// \brief A grammar element and a PrimitiveTransform that associates
68     /// a transform with the grammar.
69     ///
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.
75     ///
76     /// \code
77     /// // Count the terminals in an expression tree.
78     /// // Must be invoked with initial state == mpl::int_<0>().
79     /// struct CountLeaves
80     ///   : or_<
81     ///         when<terminal<_>, mpl::next<_state>()>
82     ///       , otherwise<fold<_, _state, CountLeaves> >
83     ///     >
84     /// {};
85     /// \endcode
86     ///
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
92     /// ObjectTransforms.
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)...)>
96     {};
97     #endif
98 
99     #undef N
100 
101 #endif
102