-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<xtree>: Fixes _Tree move constructor #1357
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
Merged
Merged
+23
−18
Conversation
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
Contributor
|
From what I read in the bug description we should also fiy the move assignment. |
In addition to being conventional, _STD expands to ::std:: which avoids any possible ambiguity.
* It's okay for container assignment to require comparator assignment. * Destroy-and-reconstruct is exception-unsafe - if reconstructing the comparator throws an exception (e.g. because the comparator attempts to allocate memory), then the container will be left with a destroyed comparator, violating its invariants. * It's intentional that container move construction/assignment performs comparator copy construction/assignment, respectively. The Standard (annoyingly!) doesn't talk about this clearly, but it's necessary to preserve container invariants. The issue is that moved-from containers still need to be in a valid-but-unspecified state (i.e. preconditionless member functions can be called), so they can be clear()ed (which is preconditionless) followed by inserting elements. This requires their comparators to still be usable. However, a moved-from comparator may not be usable - in particular, moved-from std::functions may be empty (and are, in our implementation). Therefore, because comparators must always be usable by the associative containers, they can't be moved-from. This was unclear from the way I wrote up microsoftGH-1037; there I said "`_Move_assign` also copy-assigns the comparator, then calls `_Swap_val` anyways." and I should have said that the former was intentional but the latter was undesirable.
This swaps the comparator in a slightly different order, but that's unobservable.
Member
|
Thanks! I've pushed a batch of changes:
|
StephanTLavavej
approved these changes
Oct 28, 2020
CaseyCarter
approved these changes
Oct 28, 2020
CaseyCarter
approved these changes
Oct 28, 2020
Member
|
Thanks for fixing this longstanding bug (present since at least VS 2015 and possibly all the way back to VS 2010) and improving the usability of the associative containers! 😺 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1037