diff options
Diffstat (limited to 'boost/phoenix/core/call.hpp')
-rw-r--r-- | boost/phoenix/core/call.hpp | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/boost/phoenix/core/call.hpp b/boost/phoenix/core/call.hpp index 366754757a..716dd793ba 100644 --- a/boost/phoenix/core/call.hpp +++ b/boost/phoenix/core/call.hpp @@ -14,6 +14,10 @@ #include <boost/proto/traits.hpp> #include <boost/proto/transform/impl.hpp> +#ifndef BOOST_PHOENIX_NO_VARIADIC_CALL +# include <boost/phoenix/core/detail/index_sequence.hpp> +#endif + namespace boost { namespace phoenix { namespace detail @@ -26,7 +30,7 @@ namespace boost { namespace phoenix , long Arity = proto::arity_of<Expr>::value > struct call_impl; - + template <typename Fun, typename Expr, typename State, typename Data> struct call_impl<Fun, Expr, State, Data, 0> : proto::transform_impl<Expr, State, Data> @@ -34,13 +38,13 @@ namespace boost { namespace phoenix typedef typename boost::phoenix::result_of::context<State, Data>::type context_type; - + typedef typename boost::result_of< Fun(Expr, context_type) >::type result_type; - + result_type operator()( typename call_impl::expr_param e , typename call_impl::state_param s @@ -50,6 +54,57 @@ namespace boost { namespace phoenix return Fun()(e, boost::phoenix::context(s, d)); } }; + +#ifdef BOOST_PHOENIX_NO_VARIADIC_CALL + #include <boost/phoenix/core/detail/cpp03/call.hpp> +#else + template <typename Fun, typename Expr, typename State, typename Data + , typename Indices> + struct call_impl_; + + template <typename Fun, typename Expr, typename State, typename Data + , std::size_t... Indices> + struct call_impl_<Fun, Expr, State, Data, index_sequence<Indices...> > + : proto::transform_impl<Expr, State, Data> + { + typedef + typename boost::phoenix::result_of::context<State, Data>::type + context_type; + template <std::size_t Index> + struct result_of_expr + { + typedef + typename proto::result_of::child_c<Expr, Index>::type + type; + }; + typedef + typename boost::result_of< + Fun( + typename result_of_expr<Indices>::type... + , context_type + ) + >::type + result_type; + result_type operator()( + typename call_impl_::expr_param e + , typename call_impl_::state_param s + , typename call_impl_::data_param d + ) const + { + return + Fun()( + proto::child_c<Indices>(e)... + , boost::phoenix::context(s, d) + ); + } + }; + + template <typename Fun, typename Expr, typename State, typename Data, long Arity> + struct call_impl + : call_impl_<Fun, Expr, State, Data, typename make_index_sequence<Arity>::type> + { + }; +#endif } template <typename Fun, typename Dummy = void> @@ -61,10 +116,8 @@ namespace boost { namespace phoenix : detail::call_impl<Fun, Expr, State, Data> {}; }; - - #include <boost/phoenix/core/detail/call.hpp> - } + namespace proto { template <typename Fun, typename Dummy> |