forked from boostorg/bind
Modernize mem_fn_template.hpp
This commit is contained in:
@@ -22,53 +22,46 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef R (BOOST_MEM_FN_CC T::*F) (A...);
|
typedef R (BOOST_MEM_FN_CC T::*Pm) (A...);
|
||||||
F f_;
|
Pm pm_;
|
||||||
|
|
||||||
template<class U, class... B> R call(U & u, T const *, B&... b) const
|
|
||||||
{
|
|
||||||
return (u.*f_)(b...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class U, class... B> R call(U & u, void const *, B&... b) const
|
|
||||||
{
|
|
||||||
return (get_pointer(u)->*f_)(b...);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit BOOST_MEM_FN_NAME(mf)(F f): f_(f) {}
|
explicit BOOST_MEM_FN_NAME(mf)( Pm pm ): pm_( pm ) {}
|
||||||
|
|
||||||
R operator()(T * p, A... a) const
|
template<class U,
|
||||||
|
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||||
|
class En = typename std::enable_if<
|
||||||
|
std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value
|
||||||
|
>::type
|
||||||
|
>
|
||||||
|
|
||||||
|
R operator()( U&& u, A... a ) const
|
||||||
{
|
{
|
||||||
return (p->*f_)(a...);
|
return (std::forward<U>( u ).*pm_)( std::forward<A>( a )... );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U> R operator()(U & u, A... a) const
|
template<class U,
|
||||||
|
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||||
|
class E1 = void,
|
||||||
|
class En = typename std::enable_if<
|
||||||
|
!(std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value)
|
||||||
|
>::type
|
||||||
|
>
|
||||||
|
|
||||||
|
R operator()( U&& u, A... a ) const
|
||||||
{
|
{
|
||||||
U const * p = 0;
|
return (get_pointer( std::forward<U>( u ) )->*pm_)( std::forward<A>( a )... );
|
||||||
return call(u, p, a...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U> R operator()(U const & u, A... a) const
|
bool operator==( BOOST_MEM_FN_NAME(mf) const & rhs ) const
|
||||||
{
|
{
|
||||||
U const * p = 0;
|
return pm_ == rhs.pm_;
|
||||||
return call(u, p, a...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()(T & t, A... a) const
|
bool operator!=( BOOST_MEM_FN_NAME(mf) const & rhs ) const
|
||||||
{
|
{
|
||||||
return (t.*f_)(a...);
|
return pm_ != rhs.pm_;
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(BOOST_MEM_FN_NAME(mf) const & rhs) const
|
|
||||||
{
|
|
||||||
return f_ == rhs.f_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(BOOST_MEM_FN_NAME(mf) const & rhs) const
|
|
||||||
{
|
|
||||||
return f_ != rhs.f_;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,46 +75,45 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef R (BOOST_MEM_FN_CC T::*F) (A...) const;
|
typedef R (BOOST_MEM_FN_CC T::*Pm) (A...) const;
|
||||||
F f_;
|
Pm pm_;
|
||||||
|
|
||||||
template<class U, class... B> R call(U & u, T const *, B&... b) const
|
|
||||||
{
|
|
||||||
return (u.*f_)(b...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class U, class... B> R call(U & u, void const *, B&... b) const
|
|
||||||
{
|
|
||||||
return (get_pointer(u)->*f_)(b...);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit BOOST_MEM_FN_NAME(cmf)(F f): f_(f) {}
|
explicit BOOST_MEM_FN_NAME(cmf)( Pm pm ): pm_( pm ) {}
|
||||||
|
|
||||||
R operator()(T const * p, A... a) const
|
template<class U,
|
||||||
|
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||||
|
class En = typename std::enable_if<
|
||||||
|
std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value
|
||||||
|
>::type
|
||||||
|
>
|
||||||
|
|
||||||
|
R operator()( U&& u, A... a ) const
|
||||||
{
|
{
|
||||||
return (p->*f_)(a...);
|
return (std::forward<U>( u ).*pm_)( std::forward<A>( a )... );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U> R operator()(U const & u, A... a) const
|
template<class U,
|
||||||
|
class Ud = typename _mfi::remove_cvref<U>::type,
|
||||||
|
class E1 = void,
|
||||||
|
class En = typename std::enable_if<
|
||||||
|
!(std::is_same<T, Ud>::value || std::is_base_of<T, Ud>::value)
|
||||||
|
>::type
|
||||||
|
>
|
||||||
|
|
||||||
|
R operator()( U&& u, A... a ) const
|
||||||
{
|
{
|
||||||
U const * p = 0;
|
return (get_pointer( std::forward<U>( u ) )->*pm_)( std::forward<A>( a )... );
|
||||||
return call(u, p, a...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()(T const & t, A... a) const
|
bool operator==( BOOST_MEM_FN_NAME(cmf) const & rhs ) const
|
||||||
{
|
{
|
||||||
return (t.*f_)(a...);
|
return pm_ == rhs.pm_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(BOOST_MEM_FN_NAME(cmf) const & rhs) const
|
bool operator!=( BOOST_MEM_FN_NAME(cmf) const & rhs ) const
|
||||||
{
|
{
|
||||||
return f_ == rhs.f_;
|
return pm_ != rhs.pm_;
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(BOOST_MEM_FN_NAME(cmf) const & rhs) const
|
|
||||||
{
|
|
||||||
return f_ != rhs.f_;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user