Fix some bugs in optional<T&>; add tests for them#58
Fix some bugs in optional<T&>; add tests for them#58steve-downey merged 9 commits intobemanproject:mainfrom
Conversation
`static_cast` to lvalue suppresses Clang's self-assignment warning. Add (missing?) EXPECTs to silence Clang's unused-variable warning. Add an accessor to suppress Clang's unused-private-field warning. Drive-by rename "empty_base" to "disengaged_base", since the phrase "empty base" means something different in C++.
Add two new tests: one for `optional<optional<int>&>`, and one testing that we can construct and assign to `optional<T&>` from `reference_wrapper<T>` (which should work: since `reference_wrapper<T>` is implicitly convertible to `T&`, it also should be implicitly convertible to `optional<T&>`). These tests are both red before this patch and green afterward.
The new tests are red before the patch and green afterward.
The return type of `emplace` had been wrong; `emplace` returns a reference to the emplaced value (in this case, the T& reference that was bound), not `*this`. The new tests are red before the patch and green afterward.
|
I'll merge main back to my working branch and then merge this change set on
top of it.
…On Mon, Sep 16, 2024 at 1:12 PM Quuxplusone ***@***.***> wrote:
@Quuxplusone <https://github.com/Quuxplusone> requested your review on:
#58 <#58> Fix some bugs
in optional<T&>; add tests for them as a code owner.
—
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVNZ5QZNUCF6E6DZRQ7OITZW4GQDAVCNFSM6AAAAABOJXVDYWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGI3TMOBSGY4TEMY>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
|
I've merged main and the additional tests. The changes to optional.hpp need to be done piece by piece as the diffs are large enough to confuse git. |
|
Thanks for the contributions @Quuxplusone, and welcome! |
|
@steve-downey/@neatudarius, what is the status of this PR? Were these changes applied in a different merge? |
|
They are incorporated into steve-downey#19 |
|
@camio Also, FWIW, I believe we've established that my new test E.g. I think it's uncontroversial that the return type of |
…thub-owned-actions-4d5d113fee Bump github/codeql-action from 4.31.11 to 4.32.2 in the github-owned-actions group
There's a lot of commits in this PR — feel free to cherry-pick (but I think they all need to be taken/addressed, one way or another). The really important ones are:
These also correspond to bugs and/or typos in P2988's wording; for example it has
emplacereturningoptional&instead ofT&.