This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
take_view and take_while_view's sentinel not comparable with their const iteratorSection: 25.7.10.3 [range.take.sentinel], 25.7.11.3 [range.take.while.sentinel] Status: C++23 Submitter: Tim Song Opened: 2020-06-06 Last modified: 2023-11-22
Priority: 1
View all other issues in [range.take.sentinel].
View all issues with C++23 status.
Discussion:
During reflector discussion it was noted that the issue observed in
LWG 3448(i) applies to take_view::sentinel
and take_while_view::sentinel as well.
[2020-06-15 Tim corrects a typo in the PR]
[2020-10-02; Priority set to 1 in telecon]
Should be considered together with 3406(i) and 3448(i).
[2020-10-02; Status to Tentatively Ready after five positive votes on the reflector]
[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP.]
Proposed resolution:
This wording is relative to N4861. It assumes
the maybe-const helper introduced by the P/R of LWG 3448(i).
Modify 25.7.10.3 [range.take.sentinel] as indicated:
[Drafting note: Unlike LWG 3448(i), these operators can't be easily templatized, so the approach taken here is to add an overload for the opposite constness instead. However, because
const Vmay not even be a range (and thereforeiterator_tmay not be well-formed), we need to defer instantiating the signature of the new overload until the point of use. ]
[…]namespace std::ranges { templatetemplate class take_view ::sentinel { private: using Base = conditional_t ; // exposition only template using CI = counted_iterator Basemaybe-const >>; // exposition only […] constexpr sentinel_t<Base> base() const; friend constexpr bool operator==(const CI & y, const sentinel& x); template requires sentinel_for }; }Base>, iterator_t<maybe-const >> friend constexpr bool operator==(const CI & y, const sentinel& x); friend constexpr bool operator==(const CI& y, const sentinel& x); template requires sentinel_for Base>, iterator_t<maybe-const >> friend constexpr bool operator==(const CI & y, const sentinel& x); -4- Effects: Equivalent to:
return y.count() == 0 || y.base() == x.end_;
Modify 25.7.11.3 [range.take.while.sentinel] as indicated:
[…]namespace std::ranges { templaterequires input_range && is_object_v && indirect_unary_predicate > template class take_while_view ::sentinel { […] constexpr sentinel_t<Base> base() const { return end_; } friend constexpr bool operator==(const iterator_t<Base>& x, const sentinel& y); template requires sentinel_for }; }Base>, iterator_t<maybe-const >> friend constexpr bool operator==(const iterator_t<maybe-const >& x, const sentinel& y); friend constexpr bool operator==(const iterator_t<Base>& x, const sentinel& y); templaterequires sentinel_for Base>, iterator_t<maybe-const >> friend constexpr bool operator==(const iterator_t<maybe-const >& x, const sentinel& y); -3- Effects: Equivalent to:
return y.end_ == x || !invoke(*y.pred_, *x);