-
Notifications
You must be signed in to change notification settings - Fork 5.5k
C.65 'self move' - clarify for stl members #1982
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
Comments
I think the options for self-moving classes with STL members are
(this was brought up in an older PR, but issue may give it more visibility): |
What is the next step for this one? If it would be useful, I could throw up a PR for the first bullet and let people throw darts at it. |
The premise of C.65 is fatally flawed. If |
Maybe not fatally flawed. I think the important part of C.65 is that self-move does not double delete, leak, and is no-op for However the text in the body does have the additional constraint that |
I stand by fatally flawed. The text continually references The very first sentence:
Why are we talking about copy assignment? Or are talking about move assignment, and The entire issue should just be struck thu, and replaced with: Sorry, we made a mistake. And then a new issue could be written with a different number. |
This sentence:
strongly implies that if self-move-assignment changes the value, then |
This page contradicts the rule:
I agree with the above arguments against C.65, the |
Should rule C.65: Make move assignment safe for self-assignment apply if a type has stl members?
Rule C.20: If you can avoid defining default operations, do shows an example using stl types without protecting for self-move:
The above outputs:
which happens becuse stl types generally only guarantee 'valid but unspecified' for self-move. Which should take precedence C.20 or C.65? To me, C.20 should take precedence because the rule-of-zero makes code simpler, self-moves that would cause a problem are likey bugs anyway, and developers may accidently introduce bugs when implemeting a safe self-move.
I made a previous attempt with #1938 but that was too aggresive. Maybe the PR could be reworded to preserve values for self move with an exception for stl members?
The text was updated successfully, but these errors were encountered: