-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement allocating algorithms for ranges #1383
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
Implement allocating algorithms for ranges #1383
Conversation
| _Uninitialized_backout<iter_value_t<_It>*> _Backout{ | ||
| _Temp_ptr, _RANGES _Uninitialized_move_unchecked(_First, _Mid, _Temp_ptr, _Temp_ptr + _Count1).out}; |
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 really do not like this function call as function argument.
I will most likely go over this soonish and give the result proper names
|
We are not using some of the return values from helper algorithms, such as I have for now removed the nodiscard here as it seems that this algorithm might also be a good candidate for not using nodiscard |
7ec7acd to
d343edd
Compare
|
Added |
|
FYI I tried to unify this using |
CaseyCarter
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.
Partial review
Co-authored-by: Casey Carter <cartec69@gmail.com>
CaseyCarter
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.
Through inplace_merge.
CaseyCarter
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.
Ugh, still need to look at tests.
Co-authored-by: Casey Carter <cartec69@gmail.com>
17057b8 to
68b6544
Compare
* `_Merge_move_to_buffer` shouldn't use `_Uninitialized_backout`; doing so could result in this function destroying a range of objects in the middle of the temporary buffer on exception from `iter_swap`. * `_Merge_move_to_buffer` shouldn't be using `iter_swap` anyway since we don't care about the pre-existing values in the destination range; it should indirectly_moving a la `*out = ranges::iter_move(in)`. * With the above changes, `_Merge_move_to_buffer` and `_Merge_move_from_buffer` can be refactored into a single function `_Merge_move_common`. * .`_Chunked_merge_to_buffer` and `_Chunked_merge_from_buffer` are then identical, and can be refactored into a single function `_Chunked_merge_common`.
CaseyCarter
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.
A bit of copypasta I'll apply fixes for, and one comment question.
Cleanup comment copypasta
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.
Looks good to me, just found various nitpicks and a question about comment accuracy.
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.
Approving with 3 unresolved questions about comment accuracy.
* Promote `_Isort_max` to namespace `std`; use it where appropriate in `<algorithm>` and `<execution>`. * Don't say "not less than" when we mean "greater than". * Refactor duplicate code into a `do`-`while` loop in `ranges::_Buffered_inplace_merge_common`. * Constant-propagate the value of `_Chunk` (`_Isort_max<_BidIt>`) through the body of `_Uninitialized_chunked_merge_unchecked`, remove the parameter, and bump the name to `_Uninitialized_chunked_merge_unchecked2` for ABI.
Say "Validate empty range" consistently instead of sometimes "ranges".
|
For implementing these algorithms, I thank you. Most complicated in the classic STL, they were. 👽 ⚙️ |
This implements remaining three stable algorithms. (Works towards #39.)
I am slightly worried about
inplace_mergeas I did some miniscule simplifications here and there and there are soo many .Also I really do not like all those free functions flying around. Would it make sense to keep them as static member functions of the respective CPO and only declare those that are used outside as
public?