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_NTH_RESULT_TYPE(Z, M, DATA) \ Chris@16: typedef \ Chris@16: typename when<_, BOOST_PP_CAT(A, M)>::template impl \ Chris@16: BOOST_PP_CAT(a, M); \ Chris@16: typedef typename BOOST_PP_CAT(a, M)::result_type BOOST_PP_CAT(b, M); \ Chris@16: /**/ Chris@16: Chris@16: #define BOOST_PROTO_NTH_RESULT(Z, M, DATA) \ Chris@16: detail::as_lvalue(BOOST_PP_CAT(a, M)()(e, s, d)) \ 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/call.hpp") Chris@16: #endif Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file call.hpp Chris@16: /// Contains definition of the call<> 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, (1, 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_NTH_RESULT Chris@16: #undef BOOST_PROTO_NTH_RESULT_TYPE Chris@16: Chris@16: #else Chris@16: Chris@16: #define N BOOST_PP_ITERATION() Chris@16: Chris@16: #if N > 3 Chris@16: /// \brief Call the PolymorphicFunctionObject \c Fun 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 call : transform > Chris@16: { Chris@16: template Chris@16: struct impl : transform_impl Chris@16: { Chris@16: BOOST_PP_REPEAT(N, BOOST_PROTO_NTH_RESULT_TYPE, ~) Chris@16: Chris@16: typedef detail::poly_function_traits function_traits; Chris@16: typedef typename function_traits::result_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 Fun()(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: typedef typename function_traits::function_type function_type; Chris@16: return function_type()(BOOST_PP_ENUM(N, BOOST_PROTO_NTH_RESULT, ~)); Chris@16: } Chris@16: }; Chris@16: }; Chris@16: #endif Chris@16: Chris@16: #if N > 0 Chris@16: /// \brief Call the PolymorphicFunctionObject \c Fun 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 call : transform > Chris@16: { Chris@16: template Chris@16: struct impl Chris@16: : call< Chris@16: typename detail::expand_pattern< Chris@16: proto::arity_of::value // BUGBUG this isn't right. Could be pack(_child), should use arity of child! 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: Fun 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: Chris@16: #undef N Chris@16: Chris@16: #endif