diff --git a/include/boost/bind/mem_fn.hpp b/include/boost/bind/mem_fn.hpp index 6f9fbb3b..fa23f9b2 100644 --- a/include/boost/bind/mem_fn.hpp +++ b/include/boost/bind/mem_fn.hpp @@ -21,10 +21,10 @@ // See http://www.boost.org/libs/bind/mem_fn.html for documentation. // -#include #include #include #include +#include namespace boost { @@ -32,6 +32,15 @@ namespace boost namespace _mfi { +template struct remove_cvref: std::remove_cv< typename std::remove_reference::type > +{ +}; + +} // namespace _mfi + +namespace _mfi +{ + #define BOOST_MEM_FN_NAME(X) X #define BOOST_MEM_FN_CC @@ -152,60 +161,62 @@ template class dm private: - typedef R (T::*F); - F f_; + typedef R (T::*Pm); + Pm pm_; - template R const & call(U & u, T const *) const - { - return (u.*f_); - } +public: - template R const & call(U & u, void const *) const - { - return (get_pointer(u)->*f_); - } + explicit dm( Pm pm ): pm_( pm ) {} -public: - - explicit dm(F f): f_(f) {} + template::type, + class En = typename std::enable_if< + std::is_same::value || std::is_base_of::value + >::type + > - R & operator()(T * p) const + auto operator()( U&& u ) const -> decltype( std::forward( u ).*pm_ ) { - return (p->*f_); + return std::forward( u ).*pm_; } - R const & operator()(T const * p) const - { - return (p->*f_); - } + template::type, + class E1 = void, + class En = typename std::enable_if< + !(std::is_same::value || std::is_base_of::value) + >::type + > - template R const & operator()(U const & u) const + auto operator()( U&& u ) const -> decltype( get_pointer( std::forward( u ) )->*pm_ ) { - return call(u, &u); + return get_pointer( std::forward( u ) )->*pm_; } -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) && !BOOST_WORKAROUND(__MWERKS__, < 0x3200) +#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) - R & operator()(T & t) const + template + R& operator()( U* u ) const { - return (t.*f_); + return u->*pm_; } - R const & operator()(T const & t) const + template + R const& operator()( U const* u ) const { - return (t.*f_); + return u->*pm_; } #endif - bool operator==(dm const & rhs) const + bool operator==( dm const & rhs ) const { - return f_ == rhs.f_; + return pm_ == rhs.pm_; } - bool operator!=(dm const & rhs) const + bool operator!=( dm const & rhs ) const { - return f_ != rhs.f_; + return pm_ != rhs.pm_; } };