-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement LWG-3836 std::expected<bool, E1> conversion constructor expected(const expected<U, G>&) should take precedence over expected(U&&) with operator bool
#3587
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
Merged
Stephan T. Lavavej (StephanTLavavej)
merged 6 commits into
microsoft:main
from
frederick-vs-ja:lwg-3836
Mar 28, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bb5821
Implement LWG-3836 for `optional` and add test coverage
frederick-vs-ja 585e878
Implement LWG-3836 for `expected` and add test coverage
frederick-vs-ja 65a68d9
Missing clang-format
frederick-vs-ja ca824fa
Fix `optional` test case for C++17
frederick-vs-ja 7e2e1cf
Skip one libc++ test
frederick-vs-ja 92a86f0
Fix copy-pasta
frederick-vs-ja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -662,6 +662,14 @@ namespace test_expected { | |
| test_constructors<IsNothrowConstructible::Not, IsExplicitConstructible::Yes>(); | ||
| test_constructors<IsNothrowConstructible::Yes, IsExplicitConstructible::Not>(); | ||
| test_constructors<IsNothrowConstructible::Yes, IsExplicitConstructible::Yes>(); | ||
|
|
||
| // LWG-3836 | ||
| struct BaseError {}; | ||
| struct DerivedError : BaseError {}; | ||
|
|
||
| std::expected<bool, DerivedError> e1(false); | ||
| std::expected<bool, BaseError> e2(e1); | ||
|
Comment on lines
+670
to
+671
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change requested: This test is already |
||
| assert(!e2.value()); | ||
| } | ||
|
|
||
| template <IsNothrowCopyConstructible nothrowCopyConstructible, IsNothrowMoveConstructible nothrowMoveConstructible, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing, but why is this doing a
bool_constant<conjunction_vrather than justconjunction; no change requested.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's some attempt here to improve throughput by "smashing" a complicated type to either
true_typeorfalse_typebut looking at this again, I am unsure whether we are actually achieving anything here. In cases below (e.g._AllowUnwrappingAssignment) we are introducing a newstructinstead of simply ausing, and there appears to be no short-circuit benefit to doing so. I'll record a todo on my list, but I would prefer to avoid touching this existing code in<optional>until Casey returns as there is no urgent need.