Page MenuHomePhabricator

[libc++] Implement ranges::is_partitioned
ClosedPublic

Authored by philnik on Tue, Apr 26, 1:19 AM.

Details

Reviewers
ldionne
Mordante
var-const
Group Reviewers
Restricted Project
Commits
rG37ba1b9d1ac7: [libc++] Implement ranges::is_partitioned

Diff Detail

Event Timeline

philnik created this revision.Tue, Apr 26, 1:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Apr 26, 1:19 AM
Herald added a subscriber: mgorny. · View Herald Transcript
philnik requested review of this revision.Tue, Apr 26, 1:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Apr 26, 1:19 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
var-const requested changes to this revision.Wed, Apr 27, 2:21 PM
var-const added inline comments.
libcxx/include/CMakeLists.txt
70

Please also update the Ranges status page to mark this algorithm as done.

libcxx/include/__algorithm/ranges_is_partitioned.h
2

I think you also need to update the synopsis in <algorithm>.

libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
8

You also need to add the supported language versions/etc.

10

Please add synopsis.

19

Can you also check that this SFINAEs away if given something that isn't an indirect_unary_predicate?

20

Ultranit: indent 2 spaces? Or is there a reason to use 4 spaces here?

42

Optional: I think you could implement a helper function that takes care of both the iterator/sentinel and the ranges overloads. The main advantage would be more succinct callsites:

assert(test({1, 2, 3, 4, 5}, [](int i) { return i < 3; }));
assert(test({1, 2, 3, 4}, [](int i) { return true; }));
...
43

A few additional test cases:

  • empty range;
  • single-element range;
  • the partition point is the first/the last element (check for off-by-one errors).
57

Nit: s/partitoned/partitioned/.

This revision now requires changes to proceed.Wed, Apr 27, 2:21 PM
philnik updated this revision to Diff 426639.Tue, May 3, 4:10 AM
philnik marked 8 inline comments as done.
  • Address comments
libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
42

I'll try it for the next algorithm I implement. Maybe I'll change it then for all of them.

var-const accepted this revision.Tue, May 3, 1:52 PM
This revision is now accepted and ready to land.Tue, May 3, 1:52 PM

LGTM when the CI is fixed.

philnik updated this revision to Diff 426969.Wed, May 4, 5:19 AM
  • Try to fix the modules build
philnik updated this revision to Diff 427284.Thu, May 5, 5:22 AM

Fix merge conflicts

This revision was automatically updated to reflect the committed changes.