From 769479a9640c5f8e42e417c1192cdb0f324202b1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 9 Jul 2024 20:24:19 +0300 Subject: [PATCH] Refactor _bi::dm_result<> to not form references to functions. Fixes #35. --- include/boost/bind/bind.hpp | 52 +++++++++++-------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/include/boost/bind/bind.hpp b/include/boost/bind/bind.hpp index 2d5b454e..5ec79230 100644 --- a/include/boost/bind/bind.hpp +++ b/include/boost/bind/bind.hpp @@ -737,44 +737,18 @@ template namespace _bi { -template< class Pm, int I > struct add_cref; +template struct add_cref; -template< class M, class T > struct add_cref< M T::*, 0 > +template struct add_cref { typedef M type; }; -template< class M, class T > struct add_cref< M T::*, 1 > +template struct add_cref { -#ifdef BOOST_MSVC -#pragma warning(push) -#pragma warning(disable:4180) -#endif - typedef M const & type; -#ifdef BOOST_MSVC -#pragma warning(pop) -#endif -}; - -template< class R, class T > struct add_cref< R (T::*) (), 1 > -{ - typedef void type; -}; - -template< class R, class T > struct add_cref< R (T::*) () const, 1 > -{ - typedef void type; -}; - -#if defined( __cpp_noexcept_function_type ) || defined( _NOEXCEPT_TYPES_SUPPORTED ) - -template< class R, class T > struct add_cref< R (T::*) () const noexcept, 1 > -{ - typedef void type; + typedef M const& type; }; -#endif // __cpp_noexcept_function_type - template struct isref { enum value_type { value = 0 }; @@ -790,30 +764,34 @@ template struct isref< R* > enum value_type { value = 1 }; }; -template struct dm_result +template::value> struct dm_result +{ +}; + +template struct dm_result { - typedef typename add_cref< Pm, 1 >::type type; + typedef typename add_cref< M, 1 >::type type; }; -template struct dm_result< Pm, bind_t > +template struct dm_result, false> { typedef typename bind_t::result_type result_type; - typedef typename add_cref< Pm, isref< result_type >::value >::type type; + typedef typename add_cref< M, isref< result_type >::value >::type type; }; } // namespace _bi -template< class A1, class M, class T > +template _bi::bind_t< - typename _bi::dm_result< M T::*, A1 >::type, + typename _bi::dm_result::type, _mfi::dm, typename _bi::list_av::type > BOOST_BIND( M T::*f, A1 a1 ) { - typedef typename _bi::dm_result< M T::*, A1 >::type result_type; + typedef typename _bi::dm_result::type result_type; typedef _mfi::dm F; typedef typename _bi::list_av::type list_type; return _bi::bind_t< result_type, F, list_type >( F( f ), list_type( a1 ) );