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