1 /*=============================================================================
2     Copyright (c) 2001-2007 Joel de Guzman
3     Copyright (c) 2014      John Fletcher
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 
9 #if !BOOST_PHOENIX_IS_ITERATING
10 
11 #include <boost/utility/enable_if.hpp>
12 #include <boost/type_traits/is_member_function_pointer.hpp>
13 #include <boost/phoenix/core/expression.hpp>
14 #include <boost/phoenix/core/reference.hpp>
15 #include <boost/phoenix/core/detail/function_eval.hpp>
16 #include <boost/phoenix/bind/detail/cpp03/member_function_ptr.hpp>
17 
18 namespace boost { namespace phoenix
19 {
20 
21     template <typename RT, typename ClassT, typename ClassA>
22     inline
23     typename boost::lazy_enable_if<
24       boost::is_member_function_pointer<RT (ClassT::*)()>,
25     typename detail::expression::function_eval<
26             detail::member_function_ptr<0, RT, RT(ClassT::*)()>
27           , ClassA >
28     >::type const
bind(RT (ClassT::* f)(),ClassA const & obj)29     bind(RT(ClassT::*f)(), ClassA const& obj)
30     {
31         typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type;
32         return
33             detail::expression::function_eval<fp_type, ClassA>::make(
34                 fp_type(f)
35               , obj
36             );
37     }
38 
39     template <typename RT, typename ClassT, typename ClassA>
40     inline
41     typename boost::lazy_enable_if<
42       boost::is_member_function_pointer<RT (ClassT::*)()>,
43     typename detail::expression::function_eval<
44             detail::member_function_ptr<0, RT, RT(ClassT::*)() const>
45           , ClassA >
46     >::type const
bind(RT (ClassT::* f)()const,ClassA const & obj)47     bind(RT(ClassT::*f)() const, ClassA const& obj)
48     {
49         typedef
50             detail::member_function_ptr<0, RT, RT(ClassT::*)() const>
51             fp_type;
52         return
53             detail::expression::function_eval<fp_type, ClassA>::make(
54                 fp_type(f)
55               , obj
56             );
57     }
58 
59     template <typename RT, typename ClassT>
60     inline
61     typename detail::expression::function_eval<
62             detail::member_function_ptr<0, RT, RT(ClassT::*)()>
63           , ClassT
64     >::type const
bind(RT (ClassT::* f)(),ClassT & obj)65     bind(RT(ClassT::*f)(), ClassT& obj)
66     {
67         typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type;
68         return
69             detail::expression::function_eval<
70                 fp_type
71               , ClassT
72             >::make(
73                 fp_type(f)
74               , obj
75             );
76     }
77 
78     template <typename RT, typename ClassT>
79     inline
80     typename detail::expression::function_eval<
81             detail::member_function_ptr<0, RT, RT(ClassT::*)() const>
82           , ClassT
83     >::type const
bind(RT (ClassT::* f)()const,ClassT & obj)84     bind(RT(ClassT::*f)() const, ClassT& obj)
85     {
86         typedef detail::member_function_ptr<0, RT, RT(ClassT::*)() const> fp_type;
87         return
88             detail::expression::function_eval<
89                 fp_type
90               , ClassT
91             >::make(
92                 fp_type(f)
93               , obj
94             );
95     }
96 
97 #if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES)
98     #include <boost/phoenix/bind/detail/cpp03/preprocessed/bind_member_function.hpp>
99 #else
100 
101 #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
102     #pragma wave option(preserve: 2, line: 0, output: "preprocessed/bind_member_function_" BOOST_PHOENIX_LIMIT_STR ".hpp")
103 #endif
104 
105 /*=============================================================================
106     Copyright (c) 2001-2007 Joel de Guzman
107 
108     Distributed under the Boost Software License, Version 1.0. (See accompanying
109     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
110 ==============================================================================*/
111 
112 #if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
113     #pragma wave option(preserve: 1)
114 #endif
115 
116 #define BOOST_PHOENIX_ITERATION_PARAMS                                          \
117     (3, (1, BOOST_PP_DEC(BOOST_PHOENIX_ACTOR_LIMIT),                            \
118             <boost/phoenix/bind/detail/cpp03/bind_member_function.hpp>))
119 #include BOOST_PHOENIX_ITERATE()
120 
121 #if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES)
122     #pragma wave option(output: null)
123 #endif
124 
125 #endif
126 
127 }}
128 
129 #else
130 
131     template <
132         typename RT
133       , typename ClassT
134       , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
135       , typename ClassA
136       , BOOST_PHOENIX_typename_A
137     >
138     inline
139     typename detail::expression::function_eval<
140         detail::member_function_ptr<
141             BOOST_PHOENIX_ITERATION
142           , RT
143           , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
144         >
145       , ClassA
146       , BOOST_PHOENIX_A
147     >::type const
bind(RT (ClassT::* f)(BOOST_PP_ENUM_PARAMS (BOOST_PHOENIX_ITERATION,T)),ClassA const & obj,BOOST_PHOENIX_A_const_ref_a)148     bind(
149         RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
150       , ClassA const & obj
151       , BOOST_PHOENIX_A_const_ref_a
152     )
153     {
154         typedef detail::member_function_ptr<
155             BOOST_PHOENIX_ITERATION
156           , RT
157           , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
158         > fp_type;
159         return
160             detail::expression::function_eval<
161                 fp_type
162               , ClassA
163               , BOOST_PHOENIX_A
164             >::make(
165                 fp_type(f)
166               , obj
167               , BOOST_PHOENIX_a
168             );
169     }
170 
171     template <
172         typename RT
173       , typename ClassT
174       , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
175       , typename ClassA
176       , BOOST_PHOENIX_typename_A
177     >
178     inline
179     typename detail::expression::function_eval<
180         detail::member_function_ptr<
181             BOOST_PHOENIX_ITERATION
182           , RT
183           , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const
184         >
185       , ClassA
186       , BOOST_PHOENIX_A
187     >::type const
bind(RT (ClassT::* f)(BOOST_PP_ENUM_PARAMS (BOOST_PHOENIX_ITERATION,T))const,ClassA const & obj,BOOST_PHOENIX_A_const_ref_a)188     bind(
189         RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const
190       , ClassA const & obj
191       , BOOST_PHOENIX_A_const_ref_a
192     )
193     {
194         typedef detail::member_function_ptr<
195             BOOST_PHOENIX_ITERATION
196           , RT
197           , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const
198         > fp_type;
199         return
200             detail::expression::function_eval<
201                 fp_type
202               , ClassA
203               , BOOST_PHOENIX_A
204             >::make(
205                 fp_type(f)
206               , obj
207               , BOOST_PHOENIX_a
208             );
209     }
210 
211     template <
212         typename RT
213       , typename ClassT
214       , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T)
215       , BOOST_PHOENIX_typename_A
216     >
217     inline
218     typename detail::expression::function_eval<
219         detail::member_function_ptr<
220             BOOST_PHOENIX_ITERATION
221           , RT
222           , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
223         >
224       , ClassT
225       , BOOST_PHOENIX_A
226     >::type const
bind(RT (ClassT::* f)(BOOST_PP_ENUM_PARAMS (BOOST_PHOENIX_ITERATION,T)),ClassT & obj,BOOST_PHOENIX_A_const_ref_a)227     bind(
228         RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
229       , ClassT & obj
230       , BOOST_PHOENIX_A_const_ref_a
231     )
232     {
233         typedef detail::member_function_ptr<
234             BOOST_PHOENIX_ITERATION
235           , RT
236           , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T))
237         > fp_type;
238         return
239             detail::expression::function_eval<
240                 fp_type
241               , ClassT
242               , BOOST_PHOENIX_A
243             >::make(
244                 fp_type(f)
245               , obj
246               , BOOST_PHOENIX_a
247             );
248     }
249 
250 #endif
251 
252