Page MenuHomePhabricator

[libc++][ranges] implement `std::ranges::inplace_merge`

Authored by huixie90 on Jul 27 2022, 5:20 AM.


Diff Detail

Event Timeline

huixie90 created this revision.Jul 27 2022, 5:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2022, 5:20 AM
Herald added a subscriber: mgorny. · View Herald Transcript
huixie90 updated this revision to Diff 448051.Jul 27 2022, 8:22 AM

implement tests

huixie90 published this revision for review.Jul 27 2022, 8:26 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
var-const requested changes to this revision.Jul 27 2022, 12:45 PM
var-const added a subscriber: var-const.

Thanks a lot! A few nitpicks, and let's discuss algorithm_family.h offline (I'll post a summary here afterwards).


The patch number needs to be updated.


Nit: it's best not to do these refactoring changes in this patch (for the lines that you don't otherwise modify). It increases the delta that needs to be reviewed, but more importantly, it makes it harder to navigate git blame. Ideally, such changes should go to dedicated refactoring patches which can then be added to .git-blame-ignore-revs.

This doesn't apply to the lines that you're modifying anyway -- since those would show up in git blame regardless, might as well refactor them.


Optional: consider asserting that (input.begin(), input.begin() + midIdx) and (input.begin() + midIdx, input.end()) are is_sorted.


Missing [first, mid).


Nit: s/duplictes/duplicates/.


Consider also checking mid == first + 1 and mid == last - 1 (to check for off-by-one errors).


Please copy the specification from the standard into this comment.


Ultranits: s/specify/specifies/ and s/does not/don't/.


I noticed the same with shuffle. It could be a simple oversight in the spec.


Nit: "yet" makes it a little ambiguous whether it's not constexpr in the standard or just in our implementation. I'd rephrase to inplace_merge is not constexpr in the latest finished Standard.

This revision now requires changes to proceed.Jul 27 2022, 12:45 PM
huixie90 updated this revision to Diff 448171.Jul 27 2022, 2:53 PM
huixie90 marked 9 inline comments as done.

address review feedback

huixie90 updated this revision to Diff 448175.Jul 27 2022, 2:58 PM

add newline

var-const accepted this revision.Jul 27 2022, 3:16 PM
var-const added inline comments.

Nit: since we're using _AlgPolicy, this should be _AlgFamily (no o).

This revision is now accepted and ready to land.Jul 27 2022, 3:16 PM
huixie90 updated this revision to Diff 448188.Jul 27 2022, 3:35 PM
huixie90 marked an inline comment as done.

address comments

This revision was automatically updated to reflect the committed changes.