Implement LWG3836 (https://wg21.link/LWG3836)
std::expected<bool, E1> conversion constructor expected(const expected<U, G>&) should take precedence over expected(U&&) with operator bool
Details
- Reviewers
ldionne huixie90 Mordante - Group Reviewers
Restricted Project - Commits
- rG96377e5cc1e3: [libc++][expected] Implement LWG3836
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
For std::expected, seems @huixie90 has ever add a test in ctor.u.pass.cpp.
For std::optional, I can't reproduce this issue, but I have followed the standard wording.
I finally found time to have a closer look at the patch. In general happy but I would like more test coverage to see things are correct.
@huixie90 it would be great when you also can have a look at this patch.
libcxx/include/__expected/expected.h | ||
---|---|---|
171–180 | Why not something like this? This looks closer to the wording in the issue. It saves the reader from doing mental boolean calculations when comparing the code against the wording in the standard. I would also more the new condition down so again it's closer to the wording of the standard. The new paragraph 23.5 is also added at the end and not in between. | |
226–227 | Not your change but this matches the order of the wording in the WP. | |
libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp | ||
141–149 | There are 5 changes in the wording, can you make sure there are tests for all changes? |
Thanks a lot for your review! @Mordante
libcxx/include/__expected/expected.h | ||
---|---|---|
171–180 | Seems the converts-from-any-cvref<T, expected<U, G>> is false only performed when if T is not cv bool it true, we can't put s_same<remove_cv_t<_Tp>, bool> and converts-from-any-cvref<T, expected<U, G>> in the same conjunction expression, because the result was not correct. Can we use _If here?, it's more closing to the wording. WDYT? | |
226–227 | Thanks, this looks good, done! | |
libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp | ||
141–149 | Thanks for your tips, I have add more test cases. |
I've been quite busy. I'll hope to have time to look at this patch and D154116 later this week.
LGTM after a minor fix.
libcxx/include/__expected/expected.h | ||
---|---|---|
178–179 | Some whitespace fixed. This is not done by clang-format since that breaks in C++03. |
We missed the LLVM 17 deadline.