-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<expected> Implement P0323R12 #2643
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
Have you considered empty object optimization for Empty unexpected class? |
You mean in the case |
Yes, and also |
But the second one would not benefit from any empty base class optimization as we still have to allocate the value of Also this essentially doubles the implementation size because we still have to do a lot of things. E.g. just because a type is empty does not mean its construction is trivial. So we would need to still keep a lot of the implementation. I think if the maintainers really want to one could do it but the gains seem questionable. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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.
Thanks! Video code review pending. 😸
Note to self: I still need to review <expected>
starting at class expected
, and the new test.cpp
.
Thanks to cplusplus/draft#5381 , this shouldn't be marked as strengthened.
I've pushed one more change thanks to @frederick-vs-ja's discovery in #2733 that cplusplus/draft#5381 has patched |
@AlexGuteniev Thanks for raising the Empty Base Class Optimization question (in #2643 (comment) etc). I agree with @miscco that the implementation complexity would be high and the benefits would be minimal. Specifically, only the following cases would benefit:
In these cases, we could reduce the representation from 2 bytes (empty union followed by Unlike empty allocators, empty comparators, empty function objects, etc. I think that the EBCO isn't worth the implementation complexity, throughput cost, and risk here. |
I'm speculatively mirroring this to the MSVC-internal repo - further changes can be pushed, but please notify me. |
"Standard Library Header Units: <expected> ICEs with Assertion failed: IsInClassDefn()"
I had to push an additional change to work around VSO-1543660 "Standard Library Header Units: |
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.
Reviewed product code only. I'm now going to review the test code, after which I'll prepare changes for my comments if nobody has commented otherwise. (I'm trying to avoid digging through 175 comments to see if any of these have already been rejected, but I'll probably dig through anyway before I push.)
@@ -2038,6 +2040,29 @@ namespace test_expected { | |||
} | |||
} // namespace test_expected | |||
|
|||
void test_reinit_regression() { |
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 would have preferred to have this as part of the assignment tests but meh...
Thanks for implementing this major C++23 feature - it's expected to be a popular one! 😹 😻 🎉 |
Co-authored-by: Stephan T. Lavavej <[email protected]> Co-authored-by: Casey Carter <[email protected]>
This implements
<expected>
that has been added by P0323R12.I have also incorporated the changes from WG21-P2549.
I might have been a bit too strict with constraints.
Fixes #2529