This is an archive of the discontinued LLVM Phabricator instance.

[libc++][ranges] Add subsumption tests to `[special.mem.concepts]`.
ClosedPublic

Authored by var-const on Dec 8 2021, 8:25 PM.

Details

Summary

Test that nothrow-forward-iterator subsumes nothrow-input-iterator,
nothrow-forward-range subsumes nothrow-input-range, and
nothrow-sentinel-for and sentinel_for subsume each other.

This is a follow-up to D114761.

Diff Detail

Event Timeline

var-const requested review of this revision.Dec 8 2021, 8:25 PM
var-const created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2021, 8:25 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Please let me know if you'd like to add any more subsumption tests, e.g.:

  • test that nothrow-input-iterator subsumes input_iterator (and likewise for the range);
  • test that nothrow-sentinel-for and sentinel_for subsume each other (as suggested by @Quuxplusone in the original patch).
var-const updated this revision to Diff 393021.Dec 8 2021, 8:31 PM

Update commit description.

var-const edited the summary of this revision. (Show Details)Dec 8 2021, 8:31 PM
var-const updated this revision to Diff 393220.Dec 9 2021, 10:45 AM
var-const edited the summary of this revision. (Show Details)

Squash two commits into one.

ldionne accepted this revision.Dec 9 2021, 10:46 AM
This revision is now accepted and ready to land.Dec 9 2021, 10:46 AM
Quuxplusone added inline comments.Dec 9 2021, 1:03 PM
libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
38–42

Here, requires true is unnecessary: the former should properly subsume the latter, in the sense of "proper subset".

Also, I think it is actually more important (so I'd like to see) that you test "nothrow-sentinel-for and sentinel_for subsume each other." In that case, since the subsumption is not proper, the requires true will be needed in order to make the one function more-constrained than the other.

Quuxplusone requested changes to this revision.Dec 9 2021, 1:06 PM
Quuxplusone added inline comments.
libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
38–42

Oh, and also, please always pass [iterator types by value, but] range types by forwarding reference:

constexpr bool forward_subsumes_input(std::ranges::__nothrow_input_range auto&&);

Then you can use "foo" as your forwarding range here, too, instead of dragging in a std::array dependency.

This revision now requires changes to proceed.Dec 9 2021, 1:06 PM
var-const updated this revision to Diff 393315.Dec 9 2021, 3:58 PM

Address feedback, add subsumption tests to nothrow-sentinel-for.

var-const edited the summary of this revision. (Show Details)Dec 9 2021, 3:59 PM
var-const marked 2 inline comments as done.
var-const added inline comments.
libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_forward_range.compile.pass.cpp
38–42

Done, thanks for explaining!

38–42

Thanks! Added the tests for sentinels, PTAL.

var-const updated this revision to Diff 393351.Dec 9 2021, 5:52 PM
var-const marked an inline comment as done.

Rebase on main.

This revision is now accepted and ready to land.Dec 10 2021, 1:09 PM
var-const updated this revision to Diff 393662.Dec 10 2021, 9:10 PM

Rebase on main.