Hui
16f349251f
[libc++] restrict the expected conversion constructor not compete against copy constructor ( #96101 )
...
fixes #92676
So right now clang does not like
```
std::expected<std::any, int> e1;
auto e2 = e1;
```
So basically when clang tries to do overload resolution of `auto e2 =
e1;`
It finds
```
expected(const expected&); // 1. This is OK
expected(const expected<_Up, _OtherErr>&) requires __can_convert; // 2. This needs to check its constraints
```
Then in `__can_convert`, one of the check is
```
_Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>
```
which is checking
```
is_constructible<std::any, expected<_Up, _OtherErr>&>
```
Then it looks at `std::any`'s constructor
```
template < class _ValueType,
class _Tp = decay_t<_ValueType>,
class = enable_if_t< !is_same<_Tp, any>::value && !__is_inplace_type<_ValueType>::value &&
is_copy_constructible<_Tp>::value> >
any(_ValueType&& __value);
```
In the above, `is_copy_constructible<_Tp>` expands to
```
is_copy_constructible<std::expected<std::any, int>>
```
And the above goes back to the original thing we asked : copy the
`std::expected`, which goes to the overload resolution again.
```
expected(const expected&);
expected(const expected<_Up, _OtherErr>&) requires __can_convert;
```
So the second overload results in a logical cycle.
I am not a language lawyer. We could argue that clang should give up on
the second overload which has logical cycle, as the first overload is a
perfect match.
Anyway, the fix in this patch tries to short-circuiting the second
overload's constraint check: that is, if the argument matches exact same
`expected<T, E>`, we give up immediately and let the copy constructor to
deal with it
2024-06-26 12:10:59 +01:00
..
2024-06-18 09:13:45 -04:00
2024-06-25 17:31:41 +02:00
2024-04-22 22:13:58 +02:00
2024-06-23 22:03:41 +02:00
2024-06-23 22:03:41 +02:00
2024-03-16 12:16:36 +00:00
2024-03-20 09:49:31 +01:00
2024-01-30 08:35:15 -05:00
2024-06-21 10:31:22 -04:00
2024-01-22 18:12:58 -08:00
2024-04-13 18:24:12 +02:00
2024-06-18 09:13:45 -04:00
2024-06-26 12:10:59 +01:00
2024-05-28 18:29:11 -07:00
2024-06-18 14:22:33 -04:00
2024-06-23 22:03:41 +02:00
2024-05-28 18:29:11 -07:00
2023-12-18 14:01:33 -05:00
2024-06-23 22:03:41 +02:00
2024-06-18 10:51:57 +02:00
2024-06-18 10:45:30 +02:00
2024-06-25 10:20:14 -05:00
2024-06-26 07:47:39 +01:00
2024-05-28 18:29:11 -07:00
2024-06-18 10:51:57 +02:00
2024-06-25 08:35:23 -05:00
2024-06-18 10:51:57 +02:00
2024-06-12 17:25:43 -04:00
2024-06-23 22:03:41 +02:00
2024-06-18 09:13:45 -04:00
2024-05-28 18:29:11 -07:00
2024-06-23 22:03:41 +02:00
2024-06-02 21:05:53 +02:00
2024-04-13 13:46:34 +02:00
2024-06-18 10:51:57 +02:00
2024-06-18 09:13:45 -04:00
2024-06-25 16:53:17 +02:00
2024-06-26 10:51:45 +02:00
2023-12-18 14:01:33 -05:00
2024-06-23 22:03:41 +02:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-06-18 09:13:45 -04:00
2024-06-18 09:13:45 -04:00
2024-06-18 14:22:33 -04:00
2024-06-18 11:01:43 +02:00
2024-06-17 13:09:04 +02:00
2023-12-18 14:01:33 -05:00
2024-04-22 22:13:58 +02:00
2024-06-18 09:13:45 -04:00
2023-11-27 10:54:35 -05:00
2024-06-18 11:01:43 +02:00
2023-07-06 17:21:08 +00:00
2024-06-18 09:13:45 -04:00
2024-05-27 17:51:12 -04:00
2024-06-18 09:13:45 -04:00
2024-06-18 09:13:45 -04:00
2024-05-21 15:54:08 -07:00
2024-06-18 09:13:45 -04:00
2024-04-14 15:52:56 +02:00
2024-06-01 12:20:41 +02:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-04-13 13:46:34 +02:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-04-14 15:52:56 +02:00
2024-06-20 21:40:23 +02:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-06-12 12:24:34 -04:00
2024-06-18 09:13:45 -04:00
2024-06-18 09:13:45 -04:00
2024-04-14 15:52:56 +02:00
2024-03-16 15:47:17 +01:00
2024-04-14 15:52:56 +02:00
2024-05-28 18:29:11 -07:00
2024-06-18 09:13:45 -04:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-04-22 22:13:58 +02:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2024-02-29 10:12:22 -05:00
2023-12-18 14:01:33 -05:00
2024-02-29 10:12:22 -05:00
2024-05-10 20:06:21 +02:00
2024-02-29 10:12:22 -05:00
2024-06-25 10:13:48 -05:00
2023-12-18 14:01:33 -05:00
2024-02-29 10:12:22 -05:00
2024-03-18 13:57:07 +01:00
2024-02-29 10:12:22 -05:00
2023-12-18 14:01:33 -05:00
2024-03-03 20:45:17 +01:00
2023-12-18 14:01:33 -05:00
2024-04-28 12:15:25 +02:00
2024-06-25 10:13:48 -05:00
2024-06-18 09:13:45 -04:00
2024-05-09 12:48:37 +03:00
2024-06-23 22:03:41 +02:00
2024-02-29 10:12:22 -05:00
2023-12-18 14:01:33 -05:00
2024-02-29 10:12:22 -05:00
2024-06-18 10:45:30 +02:00
2024-06-18 10:51:57 +02:00
2024-02-29 10:12:22 -05:00
2024-06-18 10:51:57 +02:00
2024-04-12 10:09:05 -04:00
2024-05-28 18:29:11 -07:00
2024-06-18 09:13:45 -04:00
2024-06-25 10:13:48 -05:00
2024-06-18 09:13:45 -04:00
2023-12-18 14:01:33 -05:00
2024-06-25 10:13:48 -05:00
2024-04-22 22:13:58 +02:00
2024-04-12 19:25:22 +02:00
2024-06-07 11:31:17 -04:00
2023-10-29 18:31:37 +01:00
2024-06-12 12:24:34 -04:00
2024-06-18 09:13:45 -04:00
2024-06-18 09:13:45 -04:00
2024-02-29 10:12:22 -05:00
2024-05-27 17:51:12 -04:00
2024-06-18 09:13:45 -04:00
2024-05-02 22:38:44 +02:00
2024-06-18 09:13:45 -04:00
2024-06-23 22:03:41 +02:00
2024-02-29 10:12:22 -05:00
2024-04-23 10:58:14 -04:00
2024-02-29 10:12:22 -05:00
2024-06-18 09:13:45 -04:00
2024-06-18 09:13:45 -04:00
2024-05-28 18:29:11 -07:00
2024-06-25 10:13:48 -05:00
2024-06-18 09:13:45 -04:00
2023-12-06 09:04:06 -05:00
2024-06-18 09:13:45 -04:00
2024-05-28 18:29:11 -07:00
2024-06-23 22:03:41 +02:00
2023-12-18 14:01:33 -05:00
2023-12-18 14:01:33 -05:00
2024-04-11 12:36:56 -04:00
2024-05-01 18:34:19 +02:00
2023-12-18 14:01:33 -05:00
2023-12-18 14:01:33 -05:00
2024-04-22 22:13:58 +02:00
2024-02-29 10:12:22 -05:00
2024-06-18 10:45:30 +02:00
2024-06-25 10:13:48 -05:00
2024-06-23 22:03:41 +02:00
2023-12-18 14:01:33 -05:00
2024-06-18 09:13:45 -04:00
2024-05-02 22:38:44 +02:00
2024-02-29 10:12:22 -05:00
2024-04-02 13:52:07 +02:00
2024-06-23 22:03:41 +02:00
2024-05-10 20:06:21 +02:00
2024-02-29 10:12:22 -05:00
2024-04-03 08:04:43 -04:00
2023-12-18 14:01:33 -05:00
2024-06-25 10:13:48 -05:00
2024-06-25 10:13:48 -05:00
2024-02-29 10:12:22 -05:00
2024-06-18 09:13:45 -04:00
2024-06-18 09:13:45 -04:00
2024-06-25 10:13:48 -05:00
2024-06-12 19:01:27 +02:00
2023-12-18 14:01:33 -05:00
2023-12-18 14:01:33 -05:00