<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.
StephanTLavavej
left a comment
There was a problem hiding this comment.
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: |
CaseyCarter
left a comment
There was a problem hiding this comment.
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.)
| } | ||
| } // namespace test_expected | ||
|
|
||
| void test_reinit_regression() { |
There was a problem hiding this comment.
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 <stl@microsoft.com> Co-authored-by: Casey Carter <Casey@Carter.net>
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