Title
move_iterator should provide iterator_category only when it models forward_iterator
Status
new
Section
[move.iterator]
Submitter
Hewill Kang

Created on 2024-07-12.00:00:00 last changed 4 months ago

Messages

Date: 2024-08-02.21:52:03

Proposed resolution:

This wording is relative to N4986.

  1. Modify [move.iterator] as indicated:

    [Drafting note: Iterator that models forward_iterator implies that iterator_traits<Iterator>::iterator_category is always valid as it satisfies the exposition-only concept cpp17-iterator.]

    -2- The member typedef-name iterator_category is defined if and only if the qualified-id iterator_traits<Iterator>::iterator_category is valid and denotes a typeIterator models forward_iterator. In that case, iterator_category denotes

    1. (2.1) — random_access_iterator_tag if the type iterator_traits<Iterator>::iterator_category models derived_from<random_access_iterator_tag>, and

    2. (2.2) — iterator_traits<Iterator>::iterator_category otherwise.

Date: 2024-08-15.00:00:00

[ 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."

Date: 2024-07-12.00:00:00

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.

History
Date User Action Args
2024-08-02 21:52:03adminsetmessages: + msg14293
2024-07-21 09:10:23adminsetmessages: + msg14256
2024-07-12 00:00:00admincreate