[libcxx-commits] [pstl] f824bb0 - [pstl] Fix incorrect usage of std::invoke_result

Ruslan Arutyunyan via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 26 06:31:52 PST 2021


Author: Ruslan Arutyunyan
Date: 2021-11-26T17:29:08+03:00
New Revision: f824bb0e36fc7099923f583e4eea4aaa7d296957

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

LOG: [pstl] Fix incorrect usage of std::invoke_result

std::invoke_result takes function object type and arguments separately
(unlike std::result_of) so, std::invoke_result_t<F()> usage is
incorrect.

On the other hand, we don't need std::invoke() semantics here at all. So
just simplifying the code without extra dependency and use trailing
return type as the fix.

Reviewed By: MikeDvorskiy

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

Added: 
    

Modified: 
    pstl/include/pstl/internal/utils.h

Removed: 
    


################################################################################
diff  --git a/pstl/include/pstl/internal/utils.h b/pstl/include/pstl/internal/utils.h
index 5de8f75814249..c181ddb4b8a65 100644
--- a/pstl/include/pstl/internal/utils.h
+++ b/pstl/include/pstl/internal/utils.h
@@ -63,15 +63,15 @@ void __invoke_if_not(std::true_type, _Fp)
 }
 
 template <typename _F1, typename _F2>
-typename std::invoke_result<_F1()>::type
-__invoke_if_else(std::true_type, _F1 __f1, _F2)
+auto
+__invoke_if_else(std::true_type, _F1 __f1, _F2) -> decltype(__f1())
 {
     return __f1();
 }
 
 template <typename _F1, typename _F2>
-typename std::invoke_result<_F2()>::type
-__invoke_if_else(std::false_type, _F1, _F2 __f2)
+auto
+__invoke_if_else(std::false_type, _F1, _F2 __f2) -> decltype(__f2())
 {
     return __f2();
 }


        


More information about the libcxx-commits mailing list