-
Notifications
You must be signed in to change notification settings - Fork 1.6k
partial_sort_copy bugfix #1088
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
StephanTLavavej
merged 5 commits into
microsoft:master
from
CaseyCarter:partial_sort_copy_fix
Aug 9, 2020
Merged
partial_sort_copy bugfix #1088
StephanTLavavej
merged 5 commits into
microsoft:master
from
CaseyCarter:partial_sort_copy_fix
Aug 9, 2020
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
Instead of assuming that the `_Val` argument to the heap helper functions is an rvalue of some type, perfect-forward it all the way into `_Push_heap_by_index` where it's finally written into the hole in the heap. This allows `partial_sort_copy` to pass in ` reference to an element in its input range which is then correctly written into the output range in `_Push_heap_by_index`. I update the `std::ranges` heap helpers similarly, and make their constraints explicit. The helpers with a `_Val` argument now accept a distinct projection to be applied to `_Val`, which will enable the implementation of `std::ranges::partial_sort_copy`. Drive-by: Replace `_unchecked` in the names of `ranges::_Make_heap_fn::_Make_heap_unchecked` and `ranges::_Sort_heap_fn::_Sort_heap_unchecked` with `_common` to be consistent with the names of other internal helpers that require the sentinel and iterator to have the same type. Promote both functions from class scope to namespace scope as need to support implementation of `partial_sort` and `partial_sort_copy`. Fixes microsoft#1086.
miscco
reviewed
Jul 25, 2020
StephanTLavavej
requested changes
Jul 25, 2020
Closed
CaseyCarter
commented
Jul 28, 2020
CaseyCarter
commented
Jul 28, 2020
Member
StephanTLavavej
left a comment
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'll push a micro-change, then this looks good to me!
StephanTLavavej
approved these changes
Jul 29, 2020
cbezault
approved these changes
Aug 5, 2020
Member
|
Thanks for finding and fixing this bug! 🪲 |
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.
Instead of assuming that the
_Valargument to the heap helper functions is an rvalue of some type, perfect-forward it all the way into_Push_heap_by_indexwhere it's finally written into the hole in the heap. This allowspartial_sort_copyto pass in a reference to an element in its input range which is then correctly written into the output range in_Push_heap_by_index.I update the
std::rangesheap helpers similarly, and make their constraints explicit. The helpers with a_Valargument now accept a distinct projection to be applied to_Val, which will enable the implementation ofstd::ranges::partial_sort_copy.Drive-by: Replace
_uncheckedin the names ofranges::_Make_heap_fn::_Make_heap_uncheckedandranges::_Sort_heap_fn::_Sort_heap_uncheckedwith_commonto be consistent with the names of other internal helpers that require the sentinel and iterator to have the same type. Promote both functions from class scope to namespace scope as needed to support implementation ofpartial_sortandpartial_sort_copy.Fixes #1086.