move_iterator
should provide iterator_category
only when it models
forward_iterator
Section: 24.5.4.2 [move.iterator] Status: New Submitter: Hewill Kang Opened: 2024-07-12 Last modified: 2024-08-31
Priority: 3
View other active issues in [move.iterator].
View all other issues in [move.iterator].
View all issues with New status.
Discussion:
Following up LWG 4116, when the underlying iterator does not satisfy forward_iterator
,
move_iterator::operator++(int)
will return void
, which fails to meet the C++17 iterator
requirements, which should not provide iterator_category
.
[2024-08-02; Reflector poll]
Set priority to 3 after reflector poll.
"NAD, would be a major breaking change to something present since C++11."
"We're knowingly breaking the rules here for backwards compatibility. Should have a note here indicating that the rule is broken for good reason, and that you should do as the Standard says and not as the Standard does."
Proposed resolution:
This wording is relative to N4986.
Modify 24.5.4.2 [move.iterator] as indicated:
[Drafting note:
Iterator
that modelsforward_iterator
implies thatiterator_traits<Iterator>::iterator_category
is always valid as it satisfies the exposition-only conceptcpp17-iterator
.]
-2- The member typedef-name
iterator_category
is defined if and only ifthe qualified-iditerator_traits<Iterator>::iterator_category
is valid and denotes a typeIterator
modelsforward_iterator
. In that case,iterator_category
denotes
(2.1) —
random_access_iterator_tag
if the typeiterator_traits<Iterator>::iterator_category
modelsderived_from<random_access_iterator_tag>
, and(2.2) —
iterator_traits<Iterator>::iterator_category
otherwise.