]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Deduce function_ref<M&() noexcept> from member object pointers.
authorTomasz Kamiński <tkaminsk@redhat.com>
Mon, 20 Oct 2025 13:19:43 +0000 (15:19 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Mon, 20 Oct 2025 15:42:19 +0000 (17:42 +0200)
Implement resolution of LWG4425.

libstdc++-v3/ChangeLog:

* include/bits/funcwrap.h (__polyfunc::__deduce_funcref):
Adjust signature produced for member object pointers.
* testsuite/20_util/function_ref/deduction.cc: Update tests.

libstdc++-v3/include/bits/funcwrap.h
libstdc++-v3/testsuite/20_util/function_ref/deduction.cc

index 1a81c9a9b466940a3ab63673a5ac74311981fc72..67fd591e9635e333fb1045f945f2e5c7323369e0 100644 (file)
@@ -546,8 +546,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        if constexpr (is_member_object_pointer_v<_Fn>)
          {
            if constexpr (is_invocable_v<_Fn, _Tr>)
-             // TODO Consider reporting issue to make this noexcept
-             return static_cast<invoke_result_t<_Fn, _Tr>(*)()>(nullptr);
+             // _GLIBCXX_RESOLVE_LIB_DEFECTS
+             // 4425. CTAD function_ref from data member pointer should produce
+             //       noexcept signature
+             return static_cast<invoke_result_t<_Fn, _Tr>(*)() noexcept>(nullptr);
          }
        else if constexpr (requires { typename __skip_first_arg<_Fn>::type; })
          return static_cast<__skip_first_arg<_Fn>::type*>(nullptr);
index 6ed2b4e5712ef461f381e97e7fb3f10e7b607a75..b034c7af07258b6566bdc66564714f34b7b43d1f 100644 (file)
@@ -89,13 +89,13 @@ S s{};
 const S cs{};
 
 static_assert( is_same_v<decltype(function_ref(nontype<&S::mem>, s)),
-                        function_ref<int&()>> );
+                        function_ref<int&() noexcept>> );
 static_assert( is_same_v<decltype(function_ref(nontype<&S::mem>, cs)),
-                        function_ref<const int&()>> );
+                        function_ref<const int&() noexcept>> );
 static_assert( is_same_v<decltype(function_ref(nontype<&S::mem>, &s)),
-                        function_ref<int&()>> );
+                        function_ref<int&() noexcept>> );
 static_assert( is_same_v<decltype(function_ref(nontype<&S::mem>, &cs)),
-                        function_ref<const int&()>> );
+                        function_ref<const int&() noexcept>> );
 static_assert( !deductible<&S::mem, int> );
 
 static_assert( is_same_v<decltype(function_ref(nontype<&S::f>, s)),