ranges::const_iterator_t<range R>
fails to accept arrays of unknown boundSection: 25.2 [ranges.syn] Status: NAD Submitter: Arthur O'Dwyer Opened: 2023-03-28 Last modified: 2023-11-07
Priority: 3
View other active issues in [ranges.syn].
View all other issues in [ranges.syn].
View all issues with NAD status.
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.
[Kona 2023-11-07; SG9]
SG9 considered this and noted it's obsolete due to LWG 3946.
To support this case now would require changing ranges::cbegin
to add a special case for arrays of unknown bound, which would require a paper.
[Kona 2023-11-07; Status changed: Open → NAD.]
Proposed resolution:
This wording is relative to N4944.
Modify 25.2 [ranges.syn] as indicated:
template<class T> using iterator_t = decltype(ranges::begin(declval<T&>())); // freestanding template<range R> using sentinel_t = decltype(ranges::end(declval<R&>())); // 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