1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
2 
3     #include <boost/proto/transform/detail/preprocessed/make.hpp>
4 
5 #elif !defined(BOOST_PP_IS_ITERATING)
6 
7     #define BOOST_PROTO_MAKE_IF(Z, M, DATA)                                                         \
8         make_if_<BOOST_PP_CAT(A, M), Expr, State, Data>                                             \
9         /**/
10 
11     #define BOOST_PROTO_MAKE_IF_TYPE(Z, M, DATA)                                                    \
12         typename BOOST_PROTO_MAKE_IF(Z, M, DATA) ::type                                             \
13         /**/
14 
15     #define BOOST_PROTO_MAKE_IF_APPLIED(Z, M, DATA)                                                 \
16         BOOST_PROTO_MAKE_IF(Z, M, DATA) ::applied ||                                                \
17         /**/
18 
19     #define BOOST_PROTO_CONSTRUCT_ARG(Z, M, DATA)                                                   \
20         detail::as_lvalue(                                                                          \
21             typename when<_, BOOST_PP_CAT(A, M)>::template impl<Expr, State, Data>()(e, s, d)       \
22         )                                                                                           \
23         /**/
24 
25     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
26         #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make.hpp")
27     #endif
28 
29     ///////////////////////////////////////////////////////////////////////////////
30     /// \file make.hpp
31     /// Contains definition of the make<> transform.
32     //
33     //  Copyright 2008 Eric Niebler. Distributed under the Boost
34     //  Software License, Version 1.0. (See accompanying file
35     //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
36 
37     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
38         #pragma wave option(preserve: 1)
39     #endif
40 
41     #define BOOST_PP_ITERATION_PARAMS_1                                                             \
42         (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/make.hpp>))
43     #include BOOST_PP_ITERATE()
44 
45     #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
46         #pragma wave option(output: null)
47     #endif
48 
49     #undef BOOST_PROTO_CONSTRUCT_ARG
50     #undef BOOST_PROTO_MAKE_IF_APPLIED
51     #undef BOOST_PROTO_MAKE_IF_TYPE
52     #undef BOOST_PROTO_MAKE_IF
53 
54 #else
55 
56     #define N BOOST_PP_ITERATION()
57 
58     namespace detail
59     {
60         #if N > 0
61 
62         template<
63             template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class R
64             BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
65           , typename Expr, typename State, typename Data
66         >
67         struct make_<
68             R<BOOST_PP_ENUM_PARAMS(N, A)>
69           , Expr, State, Data
70             BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)
71         >
72           : nested_type_if<
73                 R<BOOST_PP_ENUM(N, BOOST_PROTO_MAKE_IF_TYPE, ~)>
74               , (BOOST_PP_REPEAT(N, BOOST_PROTO_MAKE_IF_APPLIED, ~) false)
75             >
76         {};
77 
78         template<
79             template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class R
80             BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
81           , typename Expr, typename State, typename Data
82         >
83         struct make_<
84             noinvoke<R<BOOST_PP_ENUM_PARAMS(N, A)> >
85           , Expr, State, Data
86             BOOST_PROTO_TEMPLATE_ARITY_PARAM(1)
87         >
88         {
89             typedef R<BOOST_PP_ENUM(N, BOOST_PROTO_MAKE_IF_TYPE, ~)> type;
90             static bool const applied = true;
91         };
92 
93         #endif
94 
95         template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
96         struct is_applyable<R(BOOST_PP_ENUM_PARAMS(N, A))>
97           : mpl::true_
98         {};
99 
100         template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
101         struct is_applyable<R(*)(BOOST_PP_ENUM_PARAMS(N, A))>
102           : mpl::true_
103         {};
104 
105         template<typename T, typename A>
106         struct construct_<proto::expr<T, A, N>, true>
107         {
108             typedef proto::expr<T, A, N> result_type;
109 
110             template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
111             BOOST_FORCEINLINE
operator ()detail::construct_112             result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
113             {
114                 return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
115             }
116         };
117 
118         template<typename T, typename A>
119         struct construct_<proto::basic_expr<T, A, N>, true>
120         {
121             typedef proto::basic_expr<T, A, N> result_type;
122 
123             template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
124             BOOST_FORCEINLINE
operator ()detail::construct_125             result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
126             {
127                 return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
128             }
129         };
130 
131         template<typename Type BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
132         BOOST_FORCEINLINE
construct(BOOST_PP_ENUM_BINARY_PARAMS (N,A,& a))133         Type construct(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
134         {
135             return construct_<Type>()(BOOST_PP_ENUM_PARAMS(N, a));
136         }
137 
138     } // namespace detail
139 
140     /// \brief A PrimitiveTransform which computes a type by evaluating any
141     /// nested transforms and then constructs an object of that type with the
142     /// current expression, state and data, transformed according
143     /// to \c A0 through \c AN.
144     template<typename Object BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
145     struct make<Object(BOOST_PP_ENUM_PARAMS(N, A))>
146       : transform<make<Object(BOOST_PP_ENUM_PARAMS(N, A))> >
147     {
148         template<typename Expr, typename State, typename Data>
149         struct impl : transform_impl<Expr, State, Data>
150         {
151             /// \brief <tt>boost::result_of\<make\<Object\>(Expr, State, Data)\>::type</tt>
152             typedef typename detail::make_if_<Object, Expr, State, Data>::type result_type;
153 
154             /// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
155             /// for each \c x in <tt>[0,N]</tt>.
156             /// Return <tt>result_type(a0, a1,... aN)</tt>.
157             ///
158             /// \param e The current expression
159             /// \param s The current state
160             /// \param d An arbitrary data
161             BOOST_FORCEINLINE
operator ()make::impl162             result_type operator ()(
163                 typename impl::expr_param   e
164               , typename impl::state_param  s
165               , typename impl::data_param   d
166             ) const
167             {
168                 proto::detail::ignore_unused(e);
169                 proto::detail::ignore_unused(s);
170                 proto::detail::ignore_unused(d);
171                 return detail::construct<result_type>(BOOST_PP_ENUM(N, BOOST_PROTO_CONSTRUCT_ARG, DATA));
172             }
173         };
174     };
175 
176     #if N > 0
177     /// \brief A PrimitiveTransform which computes a type by evaluating any
178     /// nested transforms and then constructs an object of that type with the
179     /// current expression, state and data, transformed according
180     /// to \c A0 through \c AN.
181     template<typename Object BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
182     struct make<Object(BOOST_PP_ENUM_PARAMS(N, A)...)>
183       : transform<make<Object(BOOST_PP_ENUM_PARAMS(N, A)...)> >
184     {
185         template<typename Expr, typename State, typename Data>
186         struct impl
187           : make<
188                 typename detail::expand_pattern<
189                     proto::arity_of<Expr>::value
190                   , BOOST_PP_CAT(A, BOOST_PP_DEC(N))
191                   , detail::BOOST_PP_CAT(expand_pattern_rest_, BOOST_PP_DEC(N))<
192                         Object
193                         BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_DEC(N), A)
194                     >
195                 >::type
196             >::template impl<Expr, State, Data>
197         {};
198     };
199     #endif
200     #undef N
201 
202 #endif
203