1 #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
3 #include <boost/proto/transform/detail/preprocessed/make.hpp>
5 #elif !defined(BOOST_PP_IS_ITERATING)
7 #define BOOST_PROTO_MAKE_IF(Z, M, DATA) \
8 make_if_<BOOST_PP_CAT(A, M), Expr, State, Data> \
11 #define BOOST_PROTO_MAKE_IF_TYPE(Z, M, DATA) \
12 typename BOOST_PROTO_MAKE_IF(Z, M, DATA) ::type \
15 #define BOOST_PROTO_MAKE_IF_APPLIED(Z, M, DATA) \
16 BOOST_PROTO_MAKE_IF(Z, M, DATA) ::applied || \
19 #define BOOST_PROTO_CONSTRUCT_ARG(Z, M, DATA) \
21 typename when<_, BOOST_PP_CAT(A, M)>::template impl<Expr, State, Data>()(e, s, d) \
25 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
26 #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make.hpp")
29 ///////////////////////////////////////////////////////////////////////////////
31 /// Contains definition of the make<> transform.
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)
37 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
38 #pragma wave option(preserve: 1)
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()
45 #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
46 #pragma wave option(output: null)
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
56 #define N BOOST_PP_ITERATION()
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
68 R<BOOST_PP_ENUM_PARAMS(N, A)>
70 BOOST_PROTO_TEMPLATE_ARITY_PARAM(N)
73 R<BOOST_PP_ENUM(N, BOOST_PROTO_MAKE_IF_TYPE, ~)>
74 , (BOOST_PP_REPEAT(N, BOOST_PROTO_MAKE_IF_APPLIED, ~) false)
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
84 noinvoke<R<BOOST_PP_ENUM_PARAMS(N, A)> >
86 BOOST_PROTO_TEMPLATE_ARITY_PARAM(1)
89 typedef R<BOOST_PP_ENUM(N, BOOST_PROTO_MAKE_IF_TYPE, ~)> type;
90 static bool const applied = true;
95 template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
96 struct is_applyable<R(BOOST_PP_ENUM_PARAMS(N, A))>
100 template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
101 struct is_applyable<R(*)(BOOST_PP_ENUM_PARAMS(N, A))>
105 template<typename T, typename A>
106 struct construct_<proto::expr<T, A, N>, true>
108 typedef proto::expr<T, A, N> result_type;
110 template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
112 result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
114 return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
118 template<typename T, typename A>
119 struct construct_<proto::basic_expr<T, A, N>, true>
121 typedef proto::basic_expr<T, A, N> result_type;
123 template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
125 result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
127 return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
131 template<typename Type BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
133 Type construct(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
135 return construct_<Type>()(BOOST_PP_ENUM_PARAMS(N, a));
138 } // namespace detail
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))> >
148 template<typename Expr, typename State, typename Data>
149 struct impl : transform_impl<Expr, State, Data>
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;
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>.
158 /// \param e The current expression
159 /// \param s The current state
160 /// \param d An arbitrary data
162 result_type operator ()(
163 typename impl::expr_param e
164 , typename impl::state_param s
165 , typename impl::data_param d
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));
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)...)> >
185 template<typename Expr, typename State, typename Data>
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))<
193 BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_DEC(N), A)
196 >::template impl<Expr, State, Data>