]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Replace std::result_of with __invoke_result_t [PR114394]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 19 Mar 2024 14:02:06 +0000 (14:02 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 22 Mar 2024 22:37:57 +0000 (22:37 +0000)
Replace std::result_of with std::invoke_result, as specified in the
standard since C++17, to avoid deprecated warnings for std::result_of.

We don't have __invoke_result_t in C++11 mode, so add it as an alias
template for __invoke_result<>::type (which is what std::result_of uses
as its base class, so there's no change in functionality).

This fixes warnings given by Clang 18.

libstdc++-v3/ChangeLog:

PR libstdc++/114394
* include/std/functional (bind): Use __invoke_result_t instead
of result_of::type.
* include/std/type_traits (__invoke_result_t): New alias
template.
* testsuite/20_util/bind/ref_neg.cc: Adjust prune pattern.

libstdc++-v3/include/std/functional
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/bind/ref_neg.cc

index e02be00abe55806f351cdf037b350ac94c37e12b..766558b3ce0e79f64e92f3017f2a3fbf39078f5a 100644 (file)
@@ -556,7 +556,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       template<typename _Fn, typename _CallArgs, typename... _BArgs>
        using _Res_type_impl
-         = typename result_of< _Fn&(_Mu_type<_BArgs, _CallArgs>&&...) >::type;
+         = __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>;
 
       template<typename _CallArgs>
        using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
index 21402fd8c1321e2f9c3cf92cf0b8dc8f4e1b480f..b441bf9908f7804facc11d8c7d772805ea4aa9dc 100644 (file)
@@ -2664,6 +2664,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _Functor, _ArgTypes...
       >::type
     { };
+
+  // __invoke_result_t (std::invoke_result_t for C++11)
+  template<typename _Fn, typename... _Args>
+    using __invoke_result_t = typename __invoke_result<_Fn, _Args...>::type;
   /// @endcond
 
   template<typename _Functor, typename... _ArgTypes>
index 4a1ed8dda5f7eb89b27daf94327cd3ae1e077d7f..2db9fa8276a6958c87c2ddbee385b01335983a8e 100644 (file)
@@ -50,7 +50,7 @@ void test02()
 
 // Ignore the reasons for deduction/substitution failure in the headers.
 // Arrange for the match to work on installed trees as well as build trees.
-// { dg-prune-output "no type named 'type' in 'struct std::result_of" }
+// { dg-prune-output "no type named 'type' in 'struct std::__invoke_result" }
 
 int main()
 {