- Group Reviewers
- rGf9e58f35e905: [libcxx][ranges] Add `views::counted` CPO.
Throughout, could you use _Iter instead of _Tp and perhaps __it instead of __t? I think it conveys the meaning a bit better.
We need to test that views::counted is a CPO, see http://eel.is/c++draft/customization.point.object.
Can you add a test that views::counted(iter, diff) is SFINAEd out when diff is not convertible to the iter_difference_t of iter, per http://eel.is/c++draft/range.adaptors#range.counted-2?
I'm not immediately seeing why this is std::span<const int> and not std::span<int>, can you explain?
Can you also add a test with a forward_iterator?
I think that's fine.
Also, can you please static_assert(std::is_same_v<decltype(std::views::counted(...)), what-you-expect>);. Otherwise, we're potentially relying on conversions between span-to-const and span-to-non-const.
Let's figure out the const situation below, because it makes little sense to my understanding.
Can you also add tests for contiguous_iterator<int const*>? And for all the other iterator categories below.
Based on the CI failures, you've got some missing #include. Ship it once the CI is happy!
There are things that are implicitly-but-not-explicitly convertible to iter_difference_t<_Iter>, in which case this compiles but the wording calls for rejection.
Why the static_cast to the same type?
The forward is also unnecessary - the to_address overload for non-pointers should take by const& anyway.
For __sent shouldn't it be a move?
Yes, and naming-bikeshed: can we call it __last instead of __sent? __sent looks like it should be a variable of type _Sent/_Sp, not an _Iter.
Also on line 56, noexcept(ranges::subrange(_VSTD::forward<_Iter>(__it), _VSTD::__decay_copy(__it)))
@ldionne: The situation here is easy, unless I'm mistaken: std::views::counted((int*)iter, 8) returns a span<int>, which is implicitly convertible to span<const int>, so that's what happens.
Apply review comments. Fix build.
Now that the second parameter is a template type parameter type I'm going to keep the static_cast.