1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
2 
3     #include <boost/proto/transform/detail/preprocessed/call.hpp>
4 
5 #elif !defined(BOOST_PP_IS_ITERATING)
6 
7     #define BOOST_PROTO_NTH_RESULT_TYPE(Z, M, DATA)                                                 \
8         typedef                                                                                     \
9             typename when<_, BOOST_PP_CAT(A, M)>::template impl<Expr, State, Data>                  \
10         BOOST_PP_CAT(a, M);                                                                         \
11         typedef typename BOOST_PP_CAT(a, M)::result_type BOOST_PP_CAT(b, M);                        \
12         /**/
13 
14     #define BOOST_PROTO_NTH_RESULT(Z, M, DATA)                                                      \
15         detail::as_lvalue(BOOST_PP_CAT(a, M)()(e, s, d))                                            \
16         /**/
17 
18     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
19         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/call.hpp")
20     #endif
21 
22     ///////////////////////////////////////////////////////////////////////////////
23     /// \file call.hpp
24     /// Contains definition of the call<> transform.
25     //
26     //  Copyright 2008 Eric Niebler. Distributed under the Boost
27     //  Software License, Version 1.0. (See accompanying file
28     //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
29 
30     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
31         #pragma wave option(preserve: 1)
32     #endif
33 
34     #define BOOST_PP_ITERATION_PARAMS_1                                                             \
35         (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/call.hpp>))
36     #include BOOST_PP_ITERATE()
37 
38     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
39         #pragma wave option(output: null)
40     #endif
41 
42     #undef BOOST_PROTO_NTH_RESULT
43     #undef BOOST_PROTO_NTH_RESULT_TYPE
44 
45 #else
46 
47     #define N BOOST_PP_ITERATION()
48 
49     #if N > 3
50     /// \brief Call the PolymorphicFunctionObject \c Fun with the
51     /// current expression, state and data, transformed according
52     /// to \c A0 through \c AN.
53     template<typename Fun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
54     struct call<Fun(BOOST_PP_ENUM_PARAMS(N, A))> : transform<call<Fun(BOOST_PP_ENUM_PARAMS(N, A))> >
55     {
56         template<typename Expr, typename State, typename Data>
57         struct impl : transform_impl<Expr, State, Data>
58         {
59             BOOST_PP_REPEAT(N, BOOST_PROTO_NTH_RESULT_TYPE, ~)
60 
61             typedef detail::poly_function_traits<Fun, Fun(BOOST_PP_ENUM_PARAMS(N, b))> function_traits;
62             typedef typename function_traits::result_type result_type;
63 
64             /// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
65             /// for each \c x in <tt>[0,N]</tt>.
66             /// Return <tt>Fun()(a0, a1,... aN)</tt>.
67             ///
68             /// \param e The current expression
69             /// \param s The current state
70             /// \param d An arbitrary data
71             BOOST_FORCEINLINE
operator ()call::impl72             result_type operator ()(
73                 typename impl::expr_param   e
74               , typename impl::state_param  s
75               , typename impl::data_param   d
76             ) const
77             {
78                 typedef typename function_traits::function_type function_type;
79                 return function_type()(BOOST_PP_ENUM(N, BOOST_PROTO_NTH_RESULT, ~));
80             }
81         };
82     };
83     #endif
84 
85     #if N > 0
86     /// \brief Call the PolymorphicFunctionObject \c Fun with the
87     /// current expression, state and data, transformed according
88     /// to \c A0 through \c AN.
89     template<typename Fun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
90     struct call<Fun(BOOST_PP_ENUM_PARAMS(N, A)...)> : transform<call<Fun(BOOST_PP_ENUM_PARAMS(N, A)...)> >
91     {
92         template<typename Expr, typename State, typename Data>
93         struct impl
94           : call<
95                 typename detail::expand_pattern<
96                     proto::arity_of<Expr>::value // BUGBUG this isn't right. Could be pack(_child), should use arity of child!
97                   , BOOST_PP_CAT(A, BOOST_PP_DEC(N))
98                   , detail::BOOST_PP_CAT(expand_pattern_rest_, BOOST_PP_DEC(N))<
99                         Fun
100                         BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_DEC(N), A)
101                     >
102                 >::type
103             >::template impl<Expr, State, Data>
104         {};
105     };
106     #endif
107 
108     #undef N
109 
110 #endif
111