This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of SG9 status.

3913. ranges::const_iterator_t<range R> fails to accept arrays of unknown bound

Section: 26.2 [ranges.syn] Status: SG9 Submitter: Arthur O'Dwyer Opened: 2023-03-28 Last modified: 2023-06-01

Priority: 3

View other active issues in [ranges.syn].

View all other issues in [ranges.syn].

Discussion:

ranges::iterator_t<T> is unconstrained; but in contrast, ranges::const_iterator_t<T> constrains T to be a range, i.e., it must have an end.


    static_assert(std::is_same_v<std::ranges::iterator_t<int(&)[2]>, int*>);
    static_assert(std::is_same_v<std::ranges::iterator_t<int(&)[]>, int*>);  // OK
    static_assert(std::is_same_v<std::ranges::const_iterator_t<int(&)[2]>, const int*>);
    static_assert(std::is_same_v<std::ranges::const_iterator_t<int(&)[]>, const int*>);  // hard error

[2023-06-01; Reflector poll]

Set priority to 3 after reflector poll. Several votes for NAD. Send to SG9 to be looked at with P2836.

Proposed resolution:

This wording is relative to N4944.

  1. Modify 26.2 [ranges.syn] as indicated:

    
      template<class T>
        using iterator_t = decltype(ranges::begin(declval<T&&gt;()));    // freestanding
      template<range R>
        using sentinel_t = decltype(ranges::end(declval<R&&gt;()));      // freestanding
      template<rangeclass R>
        using const_iterator_t = const_iterator<iterator_t<R>>;       // freestanding
      template<range R>
        using const_sentinel_t = const_sentinel<sentinel_t<R>>;       // freestanding