1 /*==============================================================================
2 Copyright (c) 2005-2010 Joel de Guzman
3 Copyright (c) 2011 Thomas Heller
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #ifndef BOOST_PHOENIX_CORE_CALL_HPP
9 #define BOOST_PHOENIX_CORE_CALL_HPP
11 #include <boost/phoenix/core/limits.hpp>
12 #include <boost/phoenix/core/environment.hpp>
13 #include <boost/proto/proto_fwd.hpp>
14 #include <boost/proto/traits.hpp>
15 #include <boost/proto/transform/impl.hpp>
17 #ifndef BOOST_PHOENIX_NO_VARIADIC_CALL
18 # include <boost/phoenix/core/detail/index_sequence.hpp>
21 namespace boost { namespace phoenix
30 , long Arity = proto::arity_of<Expr>::value
34 template <typename Fun, typename Expr, typename State, typename Data>
35 struct call_impl<Fun, Expr, State, Data, 0>
36 : proto::transform_impl<Expr, State, Data>
39 typename boost::phoenix::result_of::context<State, Data>::type
43 typename boost::result_of<
44 Fun(Expr, context_type)
48 result_type operator()(
49 typename call_impl::expr_param e
50 , typename call_impl::state_param s
51 , typename call_impl::data_param d
54 return Fun()(e, boost::phoenix::context(s, d));
58 #ifdef BOOST_PHOENIX_NO_VARIADIC_CALL
59 #include <boost/phoenix/core/detail/cpp03/call.hpp>
61 template <typename Fun, typename Expr, typename State, typename Data
65 template <typename Fun, typename Expr, typename State, typename Data
66 , std::size_t... Indices>
67 struct call_impl_<Fun, Expr, State, Data, index_sequence<Indices...> >
68 : proto::transform_impl<Expr, State, Data>
71 typename boost::phoenix::result_of::context<State, Data>::type
73 template <std::size_t Index>
77 typename proto::result_of::child_c<Expr, Index>::type
81 typename boost::result_of<
83 typename result_of_expr<Indices>::type...
88 result_type operator()(
89 typename call_impl_::expr_param e
90 , typename call_impl_::state_param s
91 , typename call_impl_::data_param d
96 proto::child_c<Indices>(e)...
97 , boost::phoenix::context(s, d)
102 template <typename Fun, typename Expr, typename State, typename Data, long Arity>
104 : call_impl_<Fun, Expr, State, Data, typename make_index_sequence<Arity>::type>
110 template <typename Fun, typename Dummy = void>
112 : proto::transform<call<Fun> >
114 template <typename Expr, typename State, typename Data>
116 : detail::call_impl<Fun, Expr, State, Data>
123 template <typename Fun, typename Dummy>
124 struct is_callable<phoenix::call<Fun, Dummy> > : mpl::true_ {};