Created on 2025-11-07.00:00:00 last changed 1 month ago
Proposed resolution:
This wording is relative to N5014.
Modify [algorithms.requirements], as indicated:
-11- In the description of the algorithms, operator `+` is used for some of the iterator categories for which it does not have to be defined. In these cases the semantics of `a + n` are the same as those of
auto tmp = a; for (; n < 0; ++n) --tmp; for (; n > 0; --n) ++tmp; return tmp;Similarly, operator `-` is used for some combinations of iterators and sentinel types for which it does not have to be defined. If [`a`, `b`) denotes a range, the semantics of `b - a` in these cases are the same as those ofiter_difference_t<decltype(a)> n = 0; for (auto tmp = a; tmp != b; ++tmp) ++n; return n;and if [`b`, `a`) denotes a range, the same as those ofiter_difference_t<decltype(b)> n = 0; for (auto tmp = b; tmp != a; ++tmp) --n; return n;For each iterator `i` and sentinel `s` produced from a range `r`, the semantics of `s - i` are the same as those of an expression that has the same type, value, and value category as `ranges::distance(i, s)`.
[Note 3: The implementation can use `ranges::distance(r)` when that produces the same value as `ranges::distance(i, s)`. This can be more efficient for sized ranges. — end note]
[ Kona 2025-11-08; Status changed: Immediate → WP. ]
[ Kona 2025-11-07; approved by LWG. Status changed: New → Immediate. ]
“the semantics of `s - i` has” is not grammatically correct. Additionally, “type, value, and value category” are properties of expressions, not “semantics”.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-11 10:48:55 | admin | set | messages: + msg15710 |
| 2025-11-11 10:48:55 | admin | set | status: immediate -> wp |
| 2025-11-07 19:18:05 | admin | set | messages: + msg15592 |
| 2025-11-07 19:18:05 | admin | set | status: new -> immediate |
| 2025-11-07 06:46:59 | admin | set | messages: + msg15583 |
| 2025-11-07 00:00:00 | admin | create | |