[libcxx-commits] [libcxx] [libc++][NFC] Remove `__weak_result_type<F&>` partial specializations (PR #169969)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 28 18:44:03 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

<details>
<summary>Changes</summary>

Currently, libc++ defines partial specializations of `__weak_result_type` for function lvalue references. However, they can never be validly used.

`__weak_result_type` is only used as base classes of these classes:
- `reference_wrapper`, where it's already invalid to instantiate `reference_wrapper<F&>`;
- `__mem_fn` (the return type of `std::mem_fn`), where the template argument must be a pointer to member function type;
- `__bind_fn` (the return type of `std::bind`), where the template argument is already decayed and thus never a reference.

So `__weak_result_type<F&>` is useless and should probably be removed.

---
Full diff: https://github.com/llvm/llvm-project/pull/169969.diff


1 Files Affected:

- (modified) libcxx/include/__functional/weak_result_type.h (-20) 


``````````diff
diff --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h
index 4232bdc69dd00..7b898ecd66461 100644
--- a/libcxx/include/__functional/weak_result_type.h
+++ b/libcxx/include/__functional/weak_result_type.h
@@ -97,13 +97,6 @@ struct __weak_result_type<_Rp()> {
 #endif
 };
 
-template <class _Rp>
-struct __weak_result_type<_Rp (&)()> {
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-  using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
-#endif
-};
-
 template <class _Rp>
 struct __weak_result_type<_Rp (*)()> {
 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
@@ -116,9 +109,6 @@ struct __weak_result_type<_Rp (*)()> {
 template <class _Rp, class _A1>
 struct __weak_result_type<_Rp(_A1)> : public __unary_function<_A1, _Rp> {};
 
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (&)(_A1)> : public __unary_function<_A1, _Rp> {};
-
 template <class _Rp, class _A1>
 struct __weak_result_type<_Rp (*)(_A1)> : public __unary_function<_A1, _Rp> {};
 
@@ -142,9 +132,6 @@ struct __weak_result_type<_Rp(_A1, _A2)> : public __binary_function<_A1, _A2, _R
 template <class _Rp, class _A1, class _A2>
 struct __weak_result_type<_Rp (*)(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};
 
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (&)(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};
-
 template <class _Rp, class _Cp, class _A1>
 struct __weak_result_type<_Rp (_Cp::*)(_A1)> : public __binary_function<_Cp*, _A1, _Rp> {};
 
@@ -167,13 +154,6 @@ struct __weak_result_type<_Rp(_A1, _A2, _A3, _A4...)> {
 #endif
 };
 
-template <class _Rp, class _A1, class _A2, class _A3, class... _A4>
-struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> {
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
-  using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
-#endif
-};
-
 template <class _Rp, class _A1, class _A2, class _A3, class... _A4>
 struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> {
 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)

``````````

</details>


https://github.com/llvm/llvm-project/pull/169969


More information about the libcxx-commits mailing list