[libcxx-commits] [libcxx] 6f27eb6 - [libc++] Use the same implementation of invoke for C++03 and C++11

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 10 14:18:25 PDT 2022


Author: Nikolas Klauser
Date: 2022-06-10T23:18:20+02:00
New Revision: 6f27eb6ece324779d4d6a06b5685887afbc9465c

URL: https://github.com/llvm/llvm-project/commit/6f27eb6ece324779d4d6a06b5685887afbc9465c
DIFF: https://github.com/llvm/llvm-project/commit/6f27eb6ece324779d4d6a06b5685887afbc9465c.diff

LOG: [libc++] Use the same implementation of invoke for C++03 and C++11

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D127489

Added: 
    

Modified: 
    libcxx/include/__functional/invoke.h
    libcxx/include/__functional/mem_fn.h
    libcxx/include/__functional/reference_wrapper.h
    libcxx/include/__functional/weak_result_type.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__functional/invoke.h b/libcxx/include/__functional/invoke.h
index 52c29a4323e8..7381462ffca5 100644
--- a/libcxx/include/__functional/invoke.h
+++ b/libcxx/include/__functional/invoke.h
@@ -120,8 +120,6 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
     typedef _Rp (_FnType) (_Param..., ...);
 };
 
-#if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
-
 template <class _Rp, class _Class, class ..._Param>
 struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
 {
@@ -250,8 +248,6 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
     typedef _Rp (_FnType) (_Param..., ...);
 };
 
-#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
-
 template <class _Rp, class _Class>
 struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
 {
@@ -278,8 +274,6 @@ struct __member_pointer_class_type<_Ret _ClassType::*> {
   typedef _ClassType type;
 };
 
-#ifndef _LIBCPP_CXX03_LANG
-
 template <class _Fp, class _A0,
          class _DecayFp = typename decay<_Fp>::type,
          class _DecayA0 = typename decay<_A0>::type,
@@ -345,74 +339,67 @@ using __enable_if_bullet6 = typename enable_if
 // fall back - none of the bullets
 
 template <class ..._Args>
-auto __invoke(__any, _Args&& ...__args) -> __nat;
+__nat __invoke(__any, _Args&& ...__args);
 
 // bullets 1, 2 and 3
 
 template <class _Fp, class _A0, class ..._Args,
-          class = __enable_if_bullet1<_Fp, _A0>>
+          class = __enable_if_bullet1<_Fp, _A0> >
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype((std::declval<_A0>().*std::declval<_Fp>())(std::declval<_Args>()...))
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
-    -> decltype(      (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
-    { return          (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
+    _NOEXCEPT_(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)))
+    { return           (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); }
 
 template <class _Fp, class _A0, class ..._Args,
-          class = __enable_if_bullet2<_Fp, _A0>>
+          class = __enable_if_bullet2<_Fp, _A0> >
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype((std::declval<_A0>().get().*std::declval<_Fp>())(std::declval<_Args>()...))
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
-    -> decltype(      (__a0.get().*__f)(static_cast<_Args&&>(__args)...))
+    _NOEXCEPT_(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...)))
     { return          (__a0.get().*__f)(static_cast<_Args&&>(__args)...); }
 
 template <class _Fp, class _A0, class ..._Args,
-          class = __enable_if_bullet3<_Fp, _A0>>
+          class = __enable_if_bullet3<_Fp, _A0> >
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype(((*std::declval<_A0>()).*std::declval<_Fp>())(std::declval<_Args>()...))
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-    noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
-    -> decltype(      ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
+    _NOEXCEPT_(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)))
     { return          ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); }
 
 // bullets 4, 5 and 6
 
 template <class _Fp, class _A0,
-          class = __enable_if_bullet4<_Fp, _A0>>
+          class = __enable_if_bullet4<_Fp, _A0> >
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype(std::declval<_A0>().*std::declval<_Fp>())
 __invoke(_Fp&& __f, _A0&& __a0)
-    noexcept(noexcept(static_cast<_A0&&>(__a0).*__f))
-    -> decltype(      static_cast<_A0&&>(__a0).*__f)
+    _NOEXCEPT_(noexcept(static_cast<_A0&&>(__a0).*__f))
     { return          static_cast<_A0&&>(__a0).*__f; }
 
 template <class _Fp, class _A0,
-          class = __enable_if_bullet5<_Fp, _A0>>
+          class = __enable_if_bullet5<_Fp, _A0> >
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype(std::declval<_A0>().get().*std::declval<_Fp>())
 __invoke(_Fp&& __f, _A0&& __a0)
-    noexcept(noexcept(__a0.get().*__f))
-    -> decltype(      __a0.get().*__f)
+    _NOEXCEPT_(noexcept(__a0.get().*__f))
     { return          __a0.get().*__f; }
 
 template <class _Fp, class _A0,
-          class = __enable_if_bullet6<_Fp, _A0>>
+          class = __enable_if_bullet6<_Fp, _A0> >
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype((*std::declval<_A0>()).*std::declval<_Fp>())
 __invoke(_Fp&& __f, _A0&& __a0)
-    noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f))
-    -> decltype(      (*static_cast<_A0&&>(__a0)).*__f)
+    _NOEXCEPT_(noexcept((*static_cast<_A0&&>(__a0)).*__f))
     { return          (*static_cast<_A0&&>(__a0)).*__f; }
 
 // bullet 7
 
 template <class _Fp, class ..._Args>
 inline _LIBCPP_INLINE_VISIBILITY
-constexpr auto
+_LIBCPP_CONSTEXPR decltype(std::declval<_Fp>()(std::declval<_Args>()...))
 __invoke(_Fp&& __f, _Args&& ...__args)
-    noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
-    -> decltype(      static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
+    _NOEXCEPT_(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)))
     { return          static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); }
 
 // __invokable
@@ -420,8 +407,7 @@ template <class _Ret, class _Fp, class ..._Args>
 struct __invokable_r
 {
   template <class _XFp, class ..._XArgs>
-  static auto __try_call(int) -> decltype(
-    _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
+  static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int);
   template <class _XFp, class ..._XArgs>
   static __nat __try_call(...);
 
@@ -449,7 +435,7 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
     typedef __nothrow_invokable_r_imp _ThisT;
 
     template <class _Tp>
-    static void __test_noexcept(_Tp) noexcept;
+    static void __test_noexcept(_Tp) _NOEXCEPT;
 
     static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
         _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
@@ -485,235 +471,22 @@ struct __invoke_of
 {
 };
 
-#else
-
-// Assume that it's a functor in C++03
-template <class _Func, class... _Args>
-_LIBCPP_HIDE_FROM_ABI
-decltype(std::declval<_Func>()(std::declval<_Args>()...)) __invoke(_Func&& __func, _Args&&... __args) {
-    return static_cast<_Func&&>(__func)(static_cast<_Args&&>(__args)...);
-}
-
-template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
-struct __enable_invoke_imp;
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, true, true> {
-    typedef _Ret _Bullet1;
-    typedef _Bullet1 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, true, false>  {
-    typedef _Ret _Bullet2;
-    typedef _Bullet2 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, false, true>  {
-    typedef typename add_lvalue_reference<
-                typename __apply_cv<_T1, _Ret>::type
-            >::type _Bullet3;
-    typedef _Bullet3 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, false, false>  {
-    typedef typename add_lvalue_reference<
-                typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
-            >::type _Bullet4;
-    typedef _Bullet4 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1*, false, false>  {
-    typedef typename add_lvalue_reference<
-                typename __apply_cv<_T1, _Ret>::type
-            >::type _Bullet4;
-    typedef _Bullet4  type;
-};
-
-template <class _Fn, class _T1,
-          class _Traits = __member_pointer_traits<_Fn>,
-          class _Ret = typename _Traits::_ReturnType,
-          class _Class = typename _Traits::_ClassType>
-struct __enable_invoke : __enable_invoke_imp<
-    _Ret, _T1,
-    is_member_function_pointer<_Fn>::value,
-    is_base_of<_Class, typename remove_reference<_T1>::type>::value>
-{
-};
-
-__nat __invoke(__any, ...);
-
-// first bullet
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1) {
-    return (__t1.*__f)();
-}
-
-template <class _Fn, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
-    return (__t1.*__f)(__a0);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
-    return (__t1.*__f)(__a0, __a1);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
-    return (__t1.*__f)(__a0, __a1, __a2);
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1) {
-    return ((*__t1).*__f)();
-}
-
-template <class _Fn, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
-    return ((*__t1).*__f)(__a0);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
-    return ((*__t1).*__f)(__a0, __a1);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
-    return ((*__t1).*__f)(__a0, __a1, __a2);
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet3
-__invoke(_Fn __f, _T1& __t1) {
-    return __t1.*__f;
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet4
-__invoke(_Fn __f, _T1& __t1) {
-    return (*__t1).*__f;
-}
-
-// fifth bullet
-
-template <class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()())
-__invoke(_Fp& __f)
-{
-    return __f();
-}
-
-template <class _Fp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>()))
-__invoke(_Fp& __f, _A0& __a0)
-{
-    return __f(__a0);
-}
-
-template <class _Fp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
-__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
-{
-    return __f(__a0, __a1);
-}
-
-template <class _Fp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
-__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
-{
-    return __f(__a0, __a1, __a2);
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
 template <class _Ret, bool = is_void<_Ret>::value>
 struct __invoke_void_return_wrapper
 {
-#ifndef _LIBCPP_CXX03_LANG
     template <class ..._Args>
     static _Ret __call(_Args&&... __args) {
-        return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
-    }
-#else
-    template <class _Fn>
-    static _Ret __call(_Fn __f) {
-        return _VSTD::__invoke(__f);
-    }
-
-    template <class _Fn, class _A0>
-    static _Ret __call(_Fn __f, _A0& __a0) {
-        return _VSTD::__invoke(__f, __a0);
-    }
-
-    template <class _Fn, class _A0, class _A1>
-    static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
-        return _VSTD::__invoke(__f, __a0, __a1);
-    }
-
-    template <class _Fn, class _A0, class _A1, class _A2>
-    static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
-        return _VSTD::__invoke(__f, __a0, __a1, __a2);
+        return std::__invoke(std::forward<_Args>(__args)...);
     }
-#endif
 };
 
 template <class _Ret>
 struct __invoke_void_return_wrapper<_Ret, true>
 {
-#ifndef _LIBCPP_CXX03_LANG
     template <class ..._Args>
     static void __call(_Args&&... __args) {
-        _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
-    }
-#else
-    template <class _Fn>
-    static void __call(_Fn __f) {
-        _VSTD::__invoke(__f);
-    }
-
-    template <class _Fn, class _A0>
-    static void __call(_Fn __f, _A0& __a0) {
-        _VSTD::__invoke(__f, __a0);
+        std::__invoke(std::forward<_Args>(__args)...);
     }
-
-    template <class _Fn, class _A0, class _A1>
-    static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
-        _VSTD::__invoke(__f, __a0, __a1);
-    }
-
-    template <class _Fn, class _A0, class _A1, class _A2>
-    static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
-        _VSTD::__invoke(__f, __a0, __a1, __a2);
-    }
-#endif
 };
 
 #if _LIBCPP_STD_VER > 14

diff  --git a/libcxx/include/__functional/mem_fn.h b/libcxx/include/__functional/mem_fn.h
index 10967a8a14ec..c0018038db1a 100644
--- a/libcxx/include/__functional/mem_fn.h
+++ b/libcxx/include/__functional/mem_fn.h
@@ -39,114 +39,13 @@ class __mem_fn
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
 
-#ifndef _LIBCPP_CXX03_LANG
     // invoke
     template <class... _ArgTypes>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     typename __invoke_return<type, _ArgTypes...>::type
     operator() (_ArgTypes&&... __args) const {
-        return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
+        return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
     }
-#else
-
-    template <class _A0>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return0<type, _A0>::type
-    operator() (_A0& __a0) const {
-        return _VSTD::__invoke(__f_, __a0);
-    }
-
-    template <class _A0>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return0<type, _A0 const>::type
-    operator() (_A0 const& __a0) const {
-        return _VSTD::__invoke(__f_, __a0);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0, _A1>::type
-    operator() (_A0& __a0, _A1& __a1) const {
-        return _VSTD::__invoke(__f_, __a0, __a1);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0 const, _A1>::type
-    operator() (_A0 const& __a0, _A1& __a1) const {
-        return _VSTD::__invoke(__f_, __a0, __a1);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0, _A1 const>::type
-    operator() (_A0& __a0, _A1 const& __a1) const {
-        return _VSTD::__invoke(__f_, __a0, __a1);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0 const, _A1 const>::type
-    operator() (_A0 const& __a0, _A1 const& __a1) const {
-        return _VSTD::__invoke(__f_, __a0, __a1);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1, _A2>::type
-    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1, _A2>::type
-    operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1 const, _A2>::type
-    operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1, _A2 const>::type
-    operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
-    operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
-    operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
-    operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
-    operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(__f_, __a0, __a1, __a2);
-    }
-#endif
 };
 
 template<class _Rp, class _Tp>

diff  --git a/libcxx/include/__functional/reference_wrapper.h b/libcxx/include/__functional/reference_wrapper.h
index b7d2f873022e..497276a080f0 100644
--- a/libcxx/include/__functional/reference_wrapper.h
+++ b/libcxx/include/__functional/reference_wrapper.h
@@ -51,120 +51,13 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     type& get() const _NOEXCEPT {return *__f_;}
 
-#ifndef _LIBCPP_CXX03_LANG
     // invoke
     template <class... _ArgTypes>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     typename __invoke_of<type&, _ArgTypes...>::type
     operator() (_ArgTypes&&... __args) const {
-        return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
+        return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
     }
-#else
-
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return<type>::type
-    operator() () const {
-        return _VSTD::__invoke(get());
-    }
-
-    template <class _A0>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return0<type, _A0>::type
-    operator() (_A0& __a0) const {
-        return _VSTD::__invoke(get(), __a0);
-    }
-
-    template <class _A0>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return0<type, _A0 const>::type
-    operator() (_A0 const& __a0) const {
-        return _VSTD::__invoke(get(), __a0);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0, _A1>::type
-    operator() (_A0& __a0, _A1& __a1) const {
-        return _VSTD::__invoke(get(), __a0, __a1);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0 const, _A1>::type
-    operator() (_A0 const& __a0, _A1& __a1) const {
-        return _VSTD::__invoke(get(), __a0, __a1);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0, _A1 const>::type
-    operator() (_A0& __a0, _A1 const& __a1) const {
-        return _VSTD::__invoke(get(), __a0, __a1);
-    }
-
-    template <class _A0, class _A1>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return1<type, _A0 const, _A1 const>::type
-    operator() (_A0 const& __a0, _A1 const& __a1) const {
-        return _VSTD::__invoke(get(), __a0, __a1);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1, _A2>::type
-    operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1, _A2>::type
-    operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1 const, _A2>::type
-    operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1, _A2 const>::type
-    operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
-    operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
-    operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
-    operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-
-    template <class _A0, class _A1, class _A2>
-    _LIBCPP_INLINE_VISIBILITY
-    typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
-    operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
-        return _VSTD::__invoke(get(), __a0, __a1, __a2);
-    }
-#endif // _LIBCPP_CXX03_LANG
 };
 
 #if _LIBCPP_STD_VER > 14

diff  --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h
index 0fd08ee68275..81e4bedd2d1d 100644
--- a/libcxx/include/__functional/weak_result_type.h
+++ b/libcxx/include/__functional/weak_result_type.h
@@ -212,8 +212,6 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
 {
 };
 
-
-#ifndef _LIBCPP_CXX03_LANG
 // 3 or more arguments
 
 template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
@@ -264,59 +262,6 @@ struct __invoke_return
     typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
 };
 
-#else
-
-template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
-struct __invoke_return
-{
-    typedef typename __weak_result_type<_Fp>::result_type type;
-};
-
-template <class _Fp>
-struct __invoke_return<_Fp, false>
-{
-    typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
-};
-
-template <class _Tp, class _A0>
-struct __invoke_return0
-{
-    typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
-};
-
-template <class _Rp, class _Tp, class _A0>
-struct __invoke_return0<_Rp _Tp::*, _A0>
-{
-    typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
-};
-
-template <class _Tp, class _A0, class _A1>
-struct __invoke_return1
-{
-    typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
-                                                      declval<_A1&>())) type;
-};
-
-template <class _Rp, class _Class, class _A0, class _A1>
-struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
-    typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
-};
-
-template <class _Tp, class _A0, class _A1, class _A2>
-struct __invoke_return2
-{
-    typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
-                                                      declval<_A1&>(),
-                                                      declval<_A2&>())) type;
-};
-
-template <class _Ret, class _Class, class _A0, class _A1, class _A2>
-struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
-    typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
-};
-
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H


        


More information about the libcxx-commits mailing list