This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 25.3.2 [iterator.assoc.types] Status: New Submitter: Jiang An Opened: 2024-04-26 Last modified: 2024-06-24
Priority: 3
View all issues with New status.
Discussion:
Given an iterator type I
, currently both std::iter_value_t<I>
and
std::iterator_traits<I>::value_type
can be called the value type of I
.
These two types can be different if one specializes std::indirect_readable_traits
for
I
such that std::indirect_readable_traits<I>::value_type
is different
from I::value_type
.
std::iter_value_t<I>
and non-ranges algorithms,
along with other legacy iterator-related mechanisms, use std::iterator_traits<I>::value_type
.
But this doesn't seem clarified anywhere.
P2408R5 made the situation more complicated. In C++23, the type requirements of
non-mutating iterators passed to many legacy algorithms were changed to C++20 iterator concepts,
which are strongly associated with std::iter_value_t
. It didn't seem intended that
implementations were expected to use possibly different value types since C++23, but such reading
might be suggested by the use of concepts.
Likewise, a non-random-access iterator type I
can have two different difference types
if one specializes std::incrementable_traits
for I
such that
std::incrementable_traits<I>::difference_type
is different from I::difference_type
.
It's also unclear which one should be used for non-mutating iterator in algorithms.
[2024-06-24; Reflector poll]
Set priority to 3 after reflector poll.
Proposed resolution: