diff options
Diffstat (limited to 'boost/phoenix/bind/bind_member_function.hpp')
-rw-r--r-- | boost/phoenix/bind/bind_member_function.hpp | 287 |
1 files changed, 74 insertions, 213 deletions
diff --git a/boost/phoenix/bind/bind_member_function.hpp b/boost/phoenix/bind/bind_member_function.hpp index 498f1a0018..c3bbcda66d 100644 --- a/boost/phoenix/bind/bind_member_function.hpp +++ b/boost/phoenix/bind/bind_member_function.hpp @@ -1,256 +1,117 @@ /*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2014 John Fletcher + Copyright (c) 2016 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ -#if !BOOST_PHOENIX_IS_ITERATING - #ifndef PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP #define PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP -#include <boost/utility/enable_if.hpp> -#include <boost/type_traits/is_member_function_pointer.hpp> +#include <boost/phoenix/core/limits.hpp> + +#if defined(BOOST_PHOENIX_NO_VARIADIC_BIND) +# include <boost/phoenix/bind/detail/cpp03/bind_member_function.hpp> +#else + #include <boost/phoenix/core/expression.hpp> #include <boost/phoenix/core/reference.hpp> #include <boost/phoenix/core/detail/function_eval.hpp> -#include <boost/phoenix/bind/detail/member_function_ptr.hpp> namespace boost { namespace phoenix { - - template <typename RT, typename ClassT, typename ClassA> - inline - typename boost::lazy_enable_if< - boost::is_member_function_pointer<RT (ClassT::*)()>, - typename detail::expression::function_eval< - detail::member_function_ptr<0, RT, RT(ClassT::*)()> - , ClassA > - >::type const - bind(RT(ClassT::*f)(), ClassA const& obj) - { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type; - return - detail::expression::function_eval<fp_type, ClassA>::make( - fp_type(f) - , obj - ); - } - - template <typename RT, typename ClassT, typename ClassA> - inline - typename boost::lazy_enable_if< - boost::is_member_function_pointer<RT (ClassT::*)()>, - typename detail::expression::function_eval< - detail::member_function_ptr<0, RT, RT(ClassT::*)() const> - , ClassA > - >::type const - bind(RT(ClassT::*f)() const, ClassA const& obj) - { - typedef - detail::member_function_ptr<0, RT, RT(ClassT::*)() const> - fp_type; - return - detail::expression::function_eval<fp_type, ClassA>::make( - fp_type(f) - , obj - ); - } - - template <typename RT, typename ClassT> - inline - typename detail::expression::function_eval< - detail::member_function_ptr<0, RT, RT(ClassT::*)()> - , ClassT - >::type const - bind(RT(ClassT::*f)(), ClassT& obj) + namespace detail { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type; - return - detail::expression::function_eval< - fp_type - , ClassT - >::make( - fp_type(f) - , obj - ); - } - - template <typename RT, typename ClassT> + template <typename RT, typename FP> + struct member_function_ptr + { + typedef RT result_type; + + member_function_ptr(FP fp_) + : fp(fp_) {} + + template <typename Class, typename... A> + result_type operator()(Class& obj, A&... a) const + { + BOOST_PROTO_USE_GET_POINTER(); + + typedef typename proto::detail::class_member_traits<FP>::class_type class_type; + return (BOOST_PROTO_GET_POINTER(class_type, obj)->*fp)(a...); + } + + template <typename Class, typename... A> + result_type operator()(Class* obj, A&... a) const + { + return (obj->*fp)(a...); + } + + bool operator==(member_function_ptr const& rhs) const + { + return fp == rhs.fp; + } + + template <int M, typename RhsRT, typename RhsFP> + bool operator==(member_function_ptr<RhsRT, RhsFP> const& /*rhs*/) const + { + return false; + } + + FP fp; + }; + } // namespace boost::phoenix::detail + + template <typename RT, typename ClassT, typename... T, typename ClassA, typename... A> inline typename detail::expression::function_eval< - detail::member_function_ptr<0, RT, RT(ClassT::*)() const> - , ClassT + detail::member_function_ptr<RT, RT(ClassT::*)(T...)> + , ClassA + , A... >::type const - bind(RT(ClassT::*f)() const, ClassT& obj) + bind(RT (ClassT::*f)(T...), ClassA const & obj, A const&... a) { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)() const> fp_type; - return - detail::expression::function_eval< - fp_type - , ClassT - >::make( - fp_type(f) - , obj - ); + typedef detail::member_function_ptr<RT, RT (ClassT::*)(T...)> fp_type; + return detail::expression::function_eval<fp_type, ClassA, A...>::make(fp_type(f), obj, a...); } -#if !defined(BOOST_PHOENIX_DONT_USE_PREPROCESSED_FILES) - #include <boost/phoenix/bind/preprocessed/bind_member_function.hpp> -#else - -#if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES) - #pragma wave option(preserve: 2, line: 0, output: "preprocessed/bind_member_function_" BOOST_PHOENIX_LIMIT_STR ".hpp") -#endif - -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ - -#if defined(__WAVE__) && defined(BOOST_PHOENIX_CREATE_PREPROCESSED_FILES) - #pragma wave option(preserve: 1) -#endif - -#define BOOST_PHOENIX_ITERATION_PARAMS \ - (3, (1, BOOST_PP_DEC(BOOST_PHOENIX_ACTOR_LIMIT), \ - <boost/phoenix/bind/bind_member_function.hpp>)) -#include BOOST_PHOENIX_ITERATE() - -#if defined(__WAVE__) && defined (BOOST_PHOENIX_CREATE_PREPROCESSED_FILES) - #pragma wave option(output: null) -#endif - -#endif - -}} - -#endif - -#else - - template < - typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T) - , typename ClassA - , BOOST_PHOENIX_typename_A - > + template <typename RT, typename ClassT, typename... T, typename ClassA, typename... A> inline typename detail::expression::function_eval< - detail::member_function_ptr< - BOOST_PHOENIX_ITERATION - , RT - , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) - > + detail::member_function_ptr<RT, RT (ClassT::*)(T...) const> , ClassA - , BOOST_PHOENIX_A + , A... >::type const - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) - , ClassA const & obj - , BOOST_PHOENIX_A_const_ref_a - ) + bind(RT (ClassT::*f)(T...) const, ClassA const & obj, A const&... a) { - typedef detail::member_function_ptr< - BOOST_PHOENIX_ITERATION - , RT - , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) - > fp_type; - return - detail::expression::function_eval< - fp_type - , ClassA - , BOOST_PHOENIX_A - >::make( - fp_type(f) - , obj - , BOOST_PHOENIX_a - ); + typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> fp_type; + return detail::expression::function_eval<fp_type, ClassA, A...>::make(fp_type(f), obj, a...); } - template < - typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T) - , typename ClassA - , BOOST_PHOENIX_typename_A - > + template <typename RT, typename ClassT, typename... T, typename... A> inline typename detail::expression::function_eval< - detail::member_function_ptr< - BOOST_PHOENIX_ITERATION - , RT - , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const - > - , ClassA - , BOOST_PHOENIX_A + detail::member_function_ptr<RT, RT(ClassT::*)(T...)> + , ClassT + , A... >::type const - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const - , ClassA const & obj - , BOOST_PHOENIX_A_const_ref_a - ) + bind(RT (ClassT::*f)(T...), ClassT & obj, A const&... a) { - typedef detail::member_function_ptr< - BOOST_PHOENIX_ITERATION - , RT - , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) const - > fp_type; - return - detail::expression::function_eval< - fp_type - , ClassA - , BOOST_PHOENIX_A - >::make( - fp_type(f) - , obj - , BOOST_PHOENIX_a - ); + typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...)> fp_type; + return detail::expression::function_eval<fp_type, ClassT, A...>::make(fp_type(f), obj, a...); } - template < - typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, typename T) - , BOOST_PHOENIX_typename_A - > + template <typename RT, typename ClassT, typename... T, typename... A> inline typename detail::expression::function_eval< - detail::member_function_ptr< - BOOST_PHOENIX_ITERATION - , RT - , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) - > + detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> , ClassT - , BOOST_PHOENIX_A + , A... >::type const - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) - , ClassT & obj - , BOOST_PHOENIX_A_const_ref_a - ) + bind(RT (ClassT::*f)(T...) const, ClassT const& obj, A const&... a) { - typedef detail::member_function_ptr< - BOOST_PHOENIX_ITERATION - , RT - , RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PHOENIX_ITERATION, T)) - > fp_type; - return - detail::expression::function_eval< - fp_type - , ClassT - , BOOST_PHOENIX_A - >::make( - fp_type(f) - , obj - , BOOST_PHOENIX_a - ); + typedef detail::member_function_ptr<RT, RT(ClassT::*)(T...) const> fp_type; + return detail::expression::function_eval<fp_type, ClassT, A...>::make(fp_type(f), obj, a...); } +}} // namespace boost::phoenix #endif - +#endif |