This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
random_access_iterator
semantic constraints accidentally promote difference type
using unary negateSection: 24.3.4.13 [iterator.concept.random.access] Status: C++20 Submitter: Eric Niebler Opened: 2019-09-10 Last modified: 2021-02-25
Priority: 0
View all other issues in [iterator.concept.random.access].
View all issues with C++20 status.
Discussion:
24.3.4.13 [iterator.concept.random.access]/p2.7 says:
(b += -n)
is equal toa
Unary minus can do integer promotion. That is not the intent here.
[2019-10-12 Issue Prioritization]
Status to Tentatively Ready and priority to 0 after five positive votes on the reflector.
Proposed resolution:
This wording is relative to N4830.
Modify 24.3.4.13 [iterator.concept.random.access] as indicated:
-2- Let
a
andb
be valid iterators of typeI
such thatb
is reachable froma
aftern
applications of++a
, letD
beiter_difference_t<I>
, and letn
denote a value of typeD
.I
modelsrandom_access_iterator
only if:
(2.1) —
(a += n)
is equal tob
.[…]
(2.7) —
(b += D(-n))
is equal toa
.[…]