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.
basic_const_iterator<volatile int*>
is not a contiguous_iterator
Section: 25.5.3 [const.iterators] Status: New Submitter: Hewill Kang Opened: 2024-05-14 Last modified: 2024-06-24
Priority: 4
View other active issues in [const.iterators].
View all other issues in [const.iterators].
View all issues with New status.
Discussion:
Although volatile int*
satisfies contiguous_iterator
, due to the formula design of
iter_const_reference_t
, its result for the former will be int
, which makes
basic_const_iterator<volatile int*>
no longer a contiguous_iterator
even though its
iterator_concept
is defined as contiguous_iterator_tag
and it has a valid
operator->()
that returns const volatile int*
.
basic_const_iterator
to preserve the behavior of the underlying
iterator (except for indirection operators). The same goes for
basic_const_iterator<const volatile int*>
:
#include <iterator> #include <span> int main() { int i = 42; const volatile int* p = &i; static_assert(std::contiguous_iterator<decltype(p)>); std::span sp1{p, 1}; // ok std::basic_const_iterator it{p}; static_assert(std::same_as<decltype(it.operator->()), const volatile int*>); static_assert(std::same_as<decltype(it)::iterator_concept, std::contiguous_iterator_tag>); static_assert(std::contiguous_iterator<decltype(it)>); // failed std::span sp2{it, 1}; // failed }
[2024-06-24; Reflector poll]
Set priority to 4 after reflector poll. See also LWG 3813.
Proposed resolution: