LWG 3291 reveals deficiencies in counted_iterator
Patrick Palka

Created on 2020-02-25.00:00:00 last changed 3 months ago


Date: 2020-03-29.00:00:00

[ 2020-03-29 Issue Prioritization ]

Priority to 2 after reflector discussion.

Date: 2020-02-25.00:00:00

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.

Date User Action Args
2020-03-29 15:35:56adminsetmessages: + msg11176
2020-02-25 00:00:00admincreate