This is an archive of the discontinued LLVM Phabricator instance.

[libc++] [ranges] Uncomment operator<=> in transform and iota iterators.
ClosedPublic

Authored by Quuxplusone on Sep 29 2021, 1:30 PM.

Details

Summary
The existing tests for transform_view::iterator weren't quite right,
and can be simplified now that we have more of C++20 available to us.
Having done that, let's use the same pattern for iota_view::iterator
as well.

The transform_view test had been commented out because we were missing std::is_eq (D110515). However, it turned out that the commented-out test was a bit bogus for a couple other reasons:

  • it lacked coverage for the rewritten operators and operator==
  • it was a bit overcomplicated (especially now that std::views::transform has landed)
  • it wrongly assumed that the ContiguousView from "types.h" had non-three-way-comparable iterators

Note the design decision here to rely on the fact that (for now) random_access_iterator has no operator<=>. If we ever add one, this test's sanity-check will fail, and we'll have to go find a different legacy iterator to use instead.

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Sep 29 2021, 1:30 PM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptSep 29 2021, 1:30 PM
libcxx/include/__ranges/transform_view.h
271–276

I wonder if we should just replace this function body with = default instead. The only user-visible difference would be that it would become implicitly noexcept(auto) instead of noexcept(false).

283

Unfortunately, I am not convinced that it would be conforming to eliminate these redundant relational operators in the case that operator<=> exists. The user might have some clever way of observing whether it was actual-operator< or rewritten-candidate-operator<=> getting called. At least I'm not convinced that no such cleverness exists.

Quuxplusone retitled this revision from [libc++] [ranges] Uncomment transform_view::iterator::operator<=>. to [libc++] [ranges] Uncomment operator<=> in transform and iota iterators..
Quuxplusone edited the summary of this revision. (Show Details)
Quuxplusone added reviewers: rarutyun, jloser.

Find and fix the same issue with iota_view::iterator.

Oops, also use same_as<R> auto r = in the transform test, to match what I late-breakingly decided to do in the iota test.

ldionne accepted this revision.Oct 1 2021, 1:32 PM
This revision is now accepted and ready to land.Oct 1 2021, 1:32 PM
Mordante accepted this revision.Oct 2 2021, 5:18 AM

LGTM.