-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement P3612R1 Harmonize Proxy-Reference Operations #5848
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
Open
vmichal
wants to merge
8
commits into
microsoft:main
Choose a base branch
from
vmichal:P3612R1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+111
−7
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ec80052
Add tests for new vector<bool> and bitset reference swaps and assignm…
vmichal 4bed2e4
Add swap to bitset::reference, add operator=(bool) const.
vmichal 8c0a262
Add swap to vector<bool>::reference, make operator=(bool) const avail…
vmichal 3ab0600
Mark libcxx test std/containers/sequences/vector.bool/reference.swap.…
vmichal 8f21bc7
Mention the implemented paper P3612R1 in yvals_core.h
vmichal 5c9abf0
Silence deprecation warning in tr1 vector test.
vmichal d81ed91
Remove meaningless argument name from defaulted copy ctor.
vmichal 2418738
Deprecate std::vector<bool>::swap(reference, reference) only in C++26…
vmichal 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
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
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.
I think we should also test the functionality in constant evaluation since C++20.
E.g. we can mark this function
CONSTEXPR20.And then write
Same for some other functions.
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.
Understood; I tried to fix your comments, and a new issue surfaced:
bitset<N>::referenceis not (yet) a literal type in C++20 (it uses_CONSTEXPR23), while vector::reference is.This could be solved naturally by adding
#if _HAS_CXX23to the tests, but is that the correct solution, considering the intent of the paper that both types shall have similar (or even the same?) semantics?Making the
bitset::reference_CONSTEXPR20would require making relevant portions ofbitset_CONSTEXPR20as well though, so those changes accumulate...I can look into it, but I need some guidance or precedent for adding
constexprto declarations that are not yet required to be constexpr.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.
We can use
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 see your point.
Nevertheless, could you please clarify what the issue would be with my suggestion (replacing about a dozen instances of
_CONSTEXPR23in<bitset>with_CONSTEXPR20)? I have done this experimentally on my local branch, and things seem to work fine (complete test suite is still running, I have hand-picked several tests touching thestd::bitset).Is it purely for maximal standards conformance? Or is constexpr part of ABI?
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 guess the issue is that the standard explicitly forbids adding extra constexpr to functions ([constexpr.functions]).
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.
Well, other changes introduced by this PR violate [constexpr.functions] as well, don't they? e.g. the change to
operator=(bool) constinstd::vector<bool>::referencethat @StephanTLavavej approved (see #5848 (comment))Some degree of standards violation seems unavoidable when changes are backported... I don't mean to disagree, I'm just trying to get the correct mental model to simplify future contributions.
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'm not a language lawyer, but
operator=(bool) constwas already constexpr when it was first introduced by P2321R2, so I’d guess it doesn’t violate [constexpr.functions] (we’re just backporting the complete future functionality to an older version).I agree, but about a dozen explicit standard violations seems a bit excessive to me.
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.
Understood.
To clarify, do you expect me to implement @frederick-vs-ja's suggestion (#5848 (comment)) or postpone the resolution? Mr. Lavavej mentioned in #5847 that he will review these two PRs later. Do we (I) want his opinion on this matter, or get only approval of the final version?
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.
Implementing @frederick-vs-ja’s suggestion seems correct to me, but I’m not a maintainer.
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 personally want to leave addition of
operator=(bool) constin C++23 and later. Because it doesn't seem intended for WG21-P3612R1 to backport changes ofvector<bool>::reference, and it is intentional thatbitset::referenceshould behave consistently withvector<bool>::reference(this part is also LWG-4187). IMO, as a result,operator=(bool) constof both should be restricted in C++23 and later. But maintainer(s) may have different opinions.