Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LWG-3843 std::expected<T,E>::value() & assumes E is copy constructible #3737

Merged
merged 8 commits into from
Jun 15, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented May 27, 2023

Per LWG-3843, std::expected<int, std::unique_ptr<int>>{}.value() needs to be rejected. But currently MSVC and Clang incorrectly accept it (DevCom-1638273 and LLVM-53224).

We also need to ensure that the value() & overload also treats _Err as a const lvalue on copy.

The mandating is missing in the standard wording in [expected.void.obs] currently, which is likely another LWG issue. I've mailed LWG chair for this.

Edit: the issue is now LWG-3940.

Also speculatively generalize the resolution to `expected<void, E>`.
@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner May 27, 2023 01:44
@StephanTLavavej StephanTLavavej added the LWG Library Working Group issue label May 27, 2023
stl/inc/expected Outdated Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 6bbf146 into microsoft:main Jun 15, 2023
@StephanTLavavej
Copy link
Member

Thanks for improving our conformance to the latest Working Paper as expected! 😹 🎉 🚀

@frederick-vs-ja frederick-vs-ja deleted the lwg-3843 branch June 15, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants