1 /*=============================================================================
2 Copyright (c) 2016 Kohei Takahashi
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
8 #ifndef PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP
9 #define PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP
11 #include <boost/phoenix/core/limits.hpp>
13 #if defined(BOOST_PHOENIX_NO_VARIADIC_BIND)
14 # include <boost/phoenix/bind/detail/cpp03/bind_member_function.hpp>
17 #include <boost/phoenix/core/expression.hpp>
18 #include <boost/phoenix/core/reference.hpp>
19 #include <boost/phoenix/core/detail/function_eval.hpp>
21 namespace boost { namespace phoenix
25 template <typename RT, typename FP>
26 struct member_function_ptr
28 typedef RT result_type;
30 member_function_ptr(FP fp_)
33 template <typename Class, typename... A>
34 result_type operator()(Class& obj, A&... a) const
36 BOOST_PROTO_USE_GET_POINTER();
38 typedef typename proto::detail::class_member_traits<FP>::class_type class_type;
39 return (BOOST_PROTO_GET_POINTER(class_type, obj)->*fp)(a...);
42 template <typename Class, typename... A>
43 result_type operator()(Class* obj, A&... a) const
45 return (obj->*fp)(a...);
48 bool operator==(member_function_ptr const& rhs) const
53 template <int M, typename RhsRT, typename RhsFP>
54 bool operator==(member_function_ptr<RhsRT, RhsFP> const& /*rhs*/) const
61 } // namespace boost::phoenix::detail
63 template <typename RT, typename ClassT, typename... T, typename ClassA, typename... A>
65 typename detail::expression::function_eval<
66 detail::member_function_ptr<RT, RT(ClassT::*)(T...)>
70 bind(RT (ClassT::*f)(T...), ClassA const & obj, A const&... a)
72 typedef detail::member_function_ptr<RT, RT (ClassT::*)(T...)> fp_type;
73 return detail::expression::function_eval<fp_type, ClassA, A...>::make(fp_type(f), obj, a...);
76 template <typename RT, typename ClassT, typename... T, typename ClassA, typename... A>
78 typename detail::expression::function_eval<
79 detail::member_function_ptr<RT, RT (ClassT::*)(T...) const>
83 bind(RT (ClassT::*f)(T...) const, ClassA const & obj, A const&... a)
85 typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> fp_type;
86 return detail::expression::function_eval<fp_type, ClassA, A...>::make(fp_type(f), obj, a...);
89 template <typename RT, typename ClassT, typename... T, typename... A>
91 typename detail::expression::function_eval<
92 detail::member_function_ptr<RT, RT(ClassT::*)(T...)>
96 bind(RT (ClassT::*f)(T...), ClassT & obj, A const&... a)
98 typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...)> fp_type;
99 return detail::expression::function_eval<fp_type, ClassT, A...>::make(fp_type(f), obj, a...);
102 template <typename RT, typename ClassT, typename... T, typename... A>
104 typename detail::expression::function_eval<
105 detail::member_function_ptr<RT, RT(ClassT::*)(T...) const>
109 bind(RT (ClassT::*f)(T...) const, ClassT const& obj, A const&... a)
111 typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> fp_type;
112 return detail::expression::function_eval<fp_type, ClassT, A...>::make(fp_type(f), obj, a...);
114 }} // namespace boost::phoenix