]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/include/boost/phoenix/core/call.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / phoenix / include / boost / phoenix / core / call.hpp
1 /*==============================================================================
2 Copyright (c) 2005-2010 Joel de Guzman
3 Copyright (c) 2011 Thomas Heller
4
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
10
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>
16
17 #ifndef BOOST_PHOENIX_NO_VARIADIC_CALL
18 # include <boost/phoenix/core/detail/index_sequence.hpp>
19 #endif
20
21 namespace boost { namespace phoenix
22 {
23 namespace detail
24 {
25 template <
26 typename Fun
27 , typename Expr
28 , typename State
29 , typename Data
30 , long Arity = proto::arity_of<Expr>::value
31 >
32 struct call_impl;
33
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>
37 {
38 typedef
39 typename boost::phoenix::result_of::context<State, Data>::type
40 context_type;
41
42 typedef
43 typename boost::result_of<
44 Fun(Expr, context_type)
45 >::type
46 result_type;
47
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
52 ) const
53 {
54 return Fun()(e, boost::phoenix::context(s, d));
55 }
56 };
57
58 #ifdef BOOST_PHOENIX_NO_VARIADIC_CALL
59 #include <boost/phoenix/core/detail/cpp03/call.hpp>
60 #else
61 template <typename Fun, typename Expr, typename State, typename Data
62 , typename Indices>
63 struct call_impl_;
64
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>
69 {
70 typedef
71 typename boost::phoenix::result_of::context<State, Data>::type
72 context_type;
73 template <std::size_t Index>
74 struct result_of_expr
75 {
76 typedef
77 typename proto::result_of::child_c<Expr, Index>::type
78 type;
79 };
80 typedef
81 typename boost::result_of<
82 Fun(
83 typename result_of_expr<Indices>::type...
84 , context_type
85 )
86 >::type
87 result_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
92 ) const
93 {
94 return
95 Fun()(
96 proto::child_c<Indices>(e)...
97 , boost::phoenix::context(s, d)
98 );
99 }
100 };
101
102 template <typename Fun, typename Expr, typename State, typename Data, long Arity>
103 struct call_impl
104 : call_impl_<Fun, Expr, State, Data, typename make_index_sequence<Arity>::type>
105 {
106 };
107 #endif
108 }
109
110 template <typename Fun, typename Dummy = void>
111 struct call
112 : proto::transform<call<Fun> >
113 {
114 template <typename Expr, typename State, typename Data>
115 struct impl
116 : detail::call_impl<Fun, Expr, State, Data>
117 {};
118 };
119 }
120
121 namespace proto
122 {
123 template <typename Fun, typename Dummy>
124 struct is_callable<phoenix::call<Fun, Dummy> > : mpl::true_ {};
125 }
126 }
127
128 #endif