Chris@16: #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) Chris@16: Chris@16: #include Chris@16: Chris@16: #elif !defined(BOOST_PP_IS_ITERATING) Chris@16: Chris@16: #define BOOST_PROTO_MAKE_IF(Z, M, DATA) \ Chris@16: make_if_ \ Chris@16: /**/ Chris@16: Chris@16: #define BOOST_PROTO_MAKE_IF_TYPE(Z, M, DATA) \ Chris@16: typename BOOST_PROTO_MAKE_IF(Z, M, DATA) ::type \ Chris@16: /**/ Chris@16: Chris@16: #define BOOST_PROTO_MAKE_IF_APPLIED(Z, M, DATA) \ Chris@16: BOOST_PROTO_MAKE_IF(Z, M, DATA) ::applied || \ Chris@16: /**/ Chris@16: Chris@16: #define BOOST_PROTO_CONSTRUCT_ARG(Z, M, DATA) \ Chris@16: detail::as_lvalue( \ Chris@16: typename when<_, BOOST_PP_CAT(A, M)>::template impl()(e, s, d) \ Chris@16: ) \ Chris@16: /**/ Chris@16: Chris@16: #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) Chris@16: #pragma wave option(preserve: 2, line: 0, output: "preprocessed/make.hpp") Chris@16: #endif Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file make.hpp Chris@16: /// Contains definition of the make<> transform. Chris@16: // Chris@16: // Copyright 2008 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) Chris@16: #pragma wave option(preserve: 1) Chris@16: #endif Chris@16: Chris@16: #define BOOST_PP_ITERATION_PARAMS_1 \ Chris@16: (3, (0, BOOST_PROTO_MAX_ARITY, )) Chris@16: #include BOOST_PP_ITERATE() Chris@16: Chris@16: #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) Chris@16: #pragma wave option(output: null) Chris@16: #endif Chris@16: Chris@16: #undef BOOST_PROTO_CONSTRUCT_ARG Chris@16: #undef BOOST_PROTO_MAKE_IF_APPLIED Chris@16: #undef BOOST_PROTO_MAKE_IF_TYPE Chris@16: #undef BOOST_PROTO_MAKE_IF Chris@16: Chris@16: #else Chris@16: Chris@16: #define N BOOST_PP_ITERATION() Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: #if N > 0 Chris@16: Chris@16: template< Chris@16: template class R Chris@16: BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) Chris@16: , typename Expr, typename State, typename Data Chris@16: > Chris@16: struct make_< Chris@16: R Chris@16: , Expr, State, Data Chris@16: BOOST_PROTO_TEMPLATE_ARITY_PARAM(N) Chris@16: > Chris@16: : nested_type_if< Chris@16: R Chris@16: , (BOOST_PP_REPEAT(N, BOOST_PROTO_MAKE_IF_APPLIED, ~) false) Chris@16: > Chris@16: {}; Chris@16: Chris@16: template< Chris@16: template class R Chris@16: BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) Chris@16: , typename Expr, typename State, typename Data Chris@16: > Chris@16: struct make_< Chris@16: noinvoke > Chris@16: , Expr, State, Data Chris@16: BOOST_PROTO_TEMPLATE_ARITY_PARAM(1) Chris@16: > Chris@16: { Chris@16: typedef R type; Chris@16: static bool const applied = true; Chris@16: }; Chris@16: Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct is_applyable Chris@16: : mpl::true_ Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct is_applyable Chris@16: : mpl::true_ Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct construct_, true> Chris@16: { Chris@16: typedef proto::expr result_type; Chris@16: Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const Chris@16: { Chris@16: return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a)); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct construct_, true> Chris@16: { Chris@16: typedef proto::basic_expr result_type; Chris@16: Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const Chris@16: { Chris@16: return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a)); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: BOOST_FORCEINLINE Chris@16: Type construct(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a)) Chris@16: { Chris@16: return construct_()(BOOST_PP_ENUM_PARAMS(N, a)); Chris@16: } Chris@16: Chris@16: } // namespace detail Chris@16: Chris@16: /// \brief A PrimitiveTransform which computes a type by evaluating any Chris@16: /// nested transforms and then constructs an object of that type with the Chris@16: /// current expression, state and data, transformed according Chris@16: /// to \c A0 through \c AN. Chris@16: template Chris@16: struct make Chris@16: : transform > Chris@16: { Chris@16: template Chris@16: struct impl : transform_impl Chris@16: { Chris@16: /// \brief boost::result_of\(Expr, State, Data)\>::type Chris@16: typedef typename detail::make_if_::type result_type; Chris@16: Chris@16: /// Let \c ax be when\<_, Ax\>()(e, s, d) Chris@16: /// for each \c x in [0,N]. Chris@16: /// Return result_type(a0, a1,... aN). Chris@16: /// Chris@16: /// \param e The current expression Chris@16: /// \param s The current state Chris@16: /// \param d An arbitrary data Chris@16: BOOST_FORCEINLINE Chris@16: result_type operator ()( Chris@16: typename impl::expr_param e Chris@16: , typename impl::state_param s Chris@16: , typename impl::data_param d Chris@16: ) const Chris@16: { Chris@16: proto::detail::ignore_unused(e); Chris@16: proto::detail::ignore_unused(s); Chris@16: proto::detail::ignore_unused(d); Chris@16: return detail::construct(BOOST_PP_ENUM(N, BOOST_PROTO_CONSTRUCT_ARG, DATA)); Chris@16: } Chris@16: }; Chris@16: }; Chris@16: Chris@16: #if N > 0 Chris@16: /// \brief A PrimitiveTransform which computes a type by evaluating any Chris@16: /// nested transforms and then constructs an object of that type with the Chris@16: /// current expression, state and data, transformed according Chris@16: /// to \c A0 through \c AN. Chris@16: template Chris@16: struct make Chris@16: : transform > Chris@16: { Chris@16: template Chris@16: struct impl Chris@16: : make< Chris@16: typename detail::expand_pattern< Chris@16: proto::arity_of::value Chris@16: , BOOST_PP_CAT(A, BOOST_PP_DEC(N)) Chris@16: , detail::BOOST_PP_CAT(expand_pattern_rest_, BOOST_PP_DEC(N))< Chris@16: Object Chris@16: BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_DEC(N), A) Chris@16: > Chris@16: >::type Chris@16: >::template impl Chris@16: {}; Chris@16: }; Chris@16: #endif Chris@16: #undef N Chris@16: Chris@16: #endif