3408. LWG 3291 reveals deficiencies in counted_iterator

Section: 24.5.7.1 [counted.iterator] Status: Resolved Submitter: Patrick Palka Opened: 2020-02-25 Last modified: 2021-05-18

Priority: 2

View all other issues in [counted.iterator].

View all issues with Resolved status.

Discussion:

LWG 3291 makes changes to iota_view so that it no longer falsely claims it's a C++17 forward iterator. A side effect of this change is that the counted_iterator of an iota_view can no longer model forward_iterator, no matter what the properties of the underlying weakly_incrementable type are. For example, the following snippet is ill-formed after LWG 3291:

auto v = views::iota(0);
auto i = counted_iterator{v.begin(), 5};
static_assert(random_access_iterator<decltype(i)>); // fails after LWG 3291

The problem seems to be that counted_iterator populates its iterator_traits but it does not specify its iterator_concept, so we fall back to looking at its iterator_category to determine its C++20 iterator-ness. It seems counted_iterator should specify its iterator_concept appropriately based on the iterator_concept of the iterator it wraps.

[2020-03-29 Issue Prioritization]

Priority to 2 after reflector discussion.

[2021-05-18 Resolved by the adoption of P2259R1 at the February 2021 plenary. Status changed: New → Resolved.]

Proposed resolution: