[all-commits] [llvm/llvm-project] c3a248: [libc++] type_traits: use __is_core_convertible in...
Aaron Jacobs via All-commits
all-commits at lists.llvm.org
Tue May 24 01:24:19 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c3a24882903df5b25c011628162e82e47401f71f
https://github.com/llvm/llvm-project/commit/c3a24882903df5b25c011628162e82e47401f71f
Author: Aaron Jacobs <jacobsa at google.com>
Date: 2022-05-24 (Tue, 24 May 2022)
Changed paths:
M libcxx/include/type_traits
A libcxx/test/std/utilities/meta/meta.rel/is_invocable_r.compile.pass.cpp
A libcxx/test/std/utilities/meta/meta.rel/is_invocable_r_v.compile.pass.cpp
M libcxx/test/std/utilities/meta/meta.rel/is_nothrow_invocable.pass.cpp
Log Message:
-----------
[libc++] type_traits: use __is_core_convertible in __invokable_r.
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 __invokable_r use __is_core_convertible, which
captures the ability to use guaranteed copy elision, making the
definition correct for non-moveable types.
Fixes llvm/llvm-project#55346.
Reviewed By: #libc, philnik, EricWF
Spies: EricWF, jloser, ldionne, philnik, libcxx-commits
Differential Revision: https://reviews.llvm.org/D125300
More information about the All-commits
mailing list