element_view::iterator
in LWG 3798Section: 25.7.23.3 [range.elements.iterator] Status: New Submitter: Jiang An Opened: 2022-11-23 Last modified: 2024-07-21
Priority: 3
View other active issues in [range.elements.iterator].
View all other issues in [range.elements.iterator].
View all issues with New status.
Discussion:
In LWG 3798 (voted into WP in November 2022), iterator types of several range adaptors may have
forward_iterator_tag
or stronger iterator tag types as their iterator_category
type when
their operator*
returns rvalue references. However, the proposed resolution missed the similar change
for element_view::iterator
.
[2022-11-30; Reflector poll]
Set priority to 3 after reflector poll.
"The proposed resolution is incorrect - just because the get
expression is an xvalue doesn't mean operator*
returns by reference."
Previous resolution [SUPERSEDED]:
This wording is relative to N4917.
Modify 25.7.23.3 [range.elements.iterator] as indicated:
-2- The member typedef-name
iterator_category
is defined if and only ifBase
modelsforward_range
. In that case,iterator_category
is defined as follows: LetC
denote the typeiterator_traits<iterator_t<Base>>::iterator_category
.
(2.1) — If
std::get<N>(*current_)
is anprvalue,iterator_category
denotesinput_iterator_tag
.(2.2) — Otherwise, if
C
modelsderived_from<random_access_iterator_tag>
,iterator_category
denotesrandom_access_iterator_tag
.(2.3) — Otherwise,
iterator_category
denotesC
.
[2023-01-22; Jiang An comments and provides improved wording]
The old proposed resolution was incorrect. I think the correct criteria could be that determined from the return type of
get-element
.
Previous resolution [SUPERSEDED]:
This wording is relative to N4928.
Modify 25.7.23.3 [range.elements.iterator] as indicated:
-2- The member typedef-name
iterator_category
is defined if and only ifBase
modelsforward_range
. In that case,iterator_category
is defined as follows: LetC
denote the typeiterator_traits<iterator_t<Base>>::iterator_category
.
(2.1) — If
range_reference_t<Base>
is a reference type andstd::get<N>(*current_)
is anprvalue or neitherrange_reference_t<Base>
nortuple_element_t<N, range_reference_t<Base>
is a reference type,iterator_category
denotesinput_iterator_tag
.(2.2) — Otherwise, if
C
modelsderived_from<random_access_iterator_tag>
,iterator_category
denotesrandom_access_iterator_tag
.(2.3) — Otherwise,
iterator_category
denotesC
.
[2024-07-08; Hewill Kang provides improved wording]
Proposed resolution:
This wording is relative to N4986.
Modify 25.7.23.3 [range.elements.iterator] as indicated:
-2- The member typedef-name
iterator_category
is defined if and only ifBase
modelsforward_range
. In that case,iterator_category
is defined as follows: LetC
denote the typeiterator_traits<iterator_t<Base>>::iterator_category
.
(2.1) — If
std::get<N>(*current_)
is_reference_v<decltype(get-element(current_))>
isan rvaluefalse
,iterator_category
denotesinput_iterator_tag
.(2.2) — Otherwise, if
C
modelsderived_from<random_access_iterator_tag>
,iterator_category
denotesrandom_access_iterator_tag
.(2.3) — Otherwise,
iterator_category
denotesC
.