Merge C++03 and C++11 implementations of mem_fn and __mem_fn.
The implementation of mem_fn doesn't actually require any C++11 support. For some reason there were 17 overloads for mem_fn in C++03 when only one is needed. This patch removes the extra overloads and uses the same implementation of mem_fn in C++03 and C++11. __mem_fn does require variadics to implement the call operator. Instead of having two entirely different implementations of the __mem_fn struct, this patch uses the same __mem_fn struct but provides different call operators when variadics are not available. The only thing left in <__functional_03> is the C++03 implementation of std::function. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242959 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1238,8 +1238,6 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
|
||||
// MEMFUN
|
||||
//==============================================================================
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Tp>
|
||||
class __mem_fn
|
||||
: public __weak_result_type<_Tp>
|
||||
@@ -1253,14 +1251,38 @@ private:
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
// invoke
|
||||
template <class... _ArgTypes>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return<type, _ArgTypes...>::type
|
||||
operator() (_ArgTypes&&... __args) const
|
||||
{
|
||||
return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename __invoke_return<type, _ArgTypes...>::type
|
||||
operator() (_ArgTypes&&... __args) const {
|
||||
return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
|
||||
}
|
||||
#else
|
||||
typename __invoke_return<type>::type
|
||||
operator() () const {
|
||||
return __invoke(__f_);
|
||||
}
|
||||
|
||||
template <class _A0>
|
||||
typename __invoke_return0<type, _A0>::type
|
||||
operator() (_A0& __a0) const {
|
||||
return __invoke(__f_, __a0);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
typename __invoke_return1<type, _A0, _A1>::type
|
||||
operator() (_A0& __a0, _A1& __a1) const {
|
||||
return __invoke(__f_, __a0, __a1);
|
||||
}
|
||||
|
||||
template <class _A0, class _A1, class _A2>
|
||||
typename __invoke_return2<type, _A0, _A1, _A2>::type
|
||||
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
|
||||
return __invoke(__f_, __a0, __a1, __a2);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class _Rp, class _Tp>
|
||||
@@ -1271,8 +1293,6 @@ mem_fn(_Rp _Tp::* __pm)
|
||||
return __mem_fn<_Rp _Tp::*>(__pm);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTION
|
||||
//==============================================================================
|
||||
@@ -1860,7 +1880,11 @@ void
|
||||
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
|
||||
{return __x.swap(__y);}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#else // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#include <__functional_03>
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// BIND
|
||||
@@ -2479,15 +2503,6 @@ invoke(_Fn&& __f, _Args&&... __args) {
|
||||
|
||||
// struct hash<T*> in <memory>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// FUNCTIONAL 03
|
||||
//==============================================================================
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_VARIADICS
|
||||
#include <__functional_03>
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_FUNCTIONAL
|
||||
|
Reference in New Issue
Block a user