[libcxx-commits] [PATCH] D114624: [pstl] Fix incorrect usage of std::invoke_result
Ruslan Arutyunyan via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 26 03:08:24 PST 2021
rarutyun created this revision.
rarutyun added reviewers: ldionne, MikeDvorskiy, Quuxplusone.
rarutyun added a project: libc++.
rarutyun requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
`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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114624
Files:
pstl/include/pstl/internal/utils.h
Index: pstl/include/pstl/internal/utils.h
===================================================================
--- pstl/include/pstl/internal/utils.h
+++ pstl/include/pstl/internal/utils.h
@@ -63,15 +63,15 @@
}
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();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114624.389949.patch
Type: text/x-patch
Size: 679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211126/51a59b37/attachment.bin>
More information about the libcxx-commits
mailing list