[libcxx-commits] [PATCH] D125300: type_traits: rewrite is_invocable_r in terms of argument passing.
Aaron Jacobs via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 10 03:38:13 PDT 2022
jacobsa created this revision.
Herald added a project: All.
jacobsa requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This fixes incorrect handling of non-moveable types, adding tests for this case.
See issue 55346 <https://github.com/llvm/llvm-project/issues/55346>.
The current implementation is based on is_convertible, which is
defined <https://timsong-cpp.github.io/cppwp/n4659/meta.rel#5> in terms of
validity of the following function:
To test() {
return declval<From>();
}
But this doesn't work if To and From are both some non-moveable type, which the
definition <https://timsong-cpp.github.io/cppwp/n4659/conv#3> of implicit
conversions says should work due to guaranteed copy elision:
To to = E; // E has type From
It is this latter definition that is used in the
definition <https://timsong-cpp.github.io/cppwp/n4659/function.objects#func.require-2>
of INVOKE<R>. Make is_invocable_r use an implementation that captures the
ability to use guaranteed copy elision, making the definition correct for
non-moveable types.
Fixes llvm/llvm-project#55346.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125300
Files:
libcxx/include/type_traits
libcxx/test/libcxx/type_traits/is_invocable_r.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125300.428329.patch
Type: text/x-patch
Size: 7947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220510/ff7eaa1f/attachment.bin>
More information about the libcxx-commits
mailing list