Created on 2021-06-03.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4885.
Modify [range.sized] as indicated:
template<class T> concept sized_range = range<T> && requires(T& t) { ranges::size(t); };-2- Given an lvalue t of type remove_reference_t<T>, T models sized_range only if
(2.1) — ranges::size(t) is amortized 𝒪(1), does not modify t, and is equal to ranges::distance(ranges::begin(t), ranges::end(t)
t), and(2.2) — if iterator_t<T> models forward_iterator, ranges::size(t) is well-defined regardless of the evaluation of ranges::begin(t).
[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-06-14; Reflector poll ]
Set status to Tentatively Ready after seven votes in favour during reflector poll.
[range.sized] p2.1 requires that for a sized_range t, ranges::size(t) is equal to ranges::distance(t). But for a sized_range, ranges::distance(t) is simply ranges::size(t) cast to the difference type.
Presumably what we meant is that distance(begin, end) — the actual distance you get from traversing the range — is equal to what ranges::size produces, and not merely that casting from the size type to difference type is value-preserving. Otherwise, sized_range would be more or less meaningless.History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-10-14 09:56:08 | admin | set | messages: + msg12125 |
2021-10-14 09:56:08 | admin | set | status: voting -> wp |
2021-09-29 12:57:28 | admin | set | status: ready -> voting |
2021-06-14 14:09:34 | admin | set | messages: + msg11928 |
2021-06-14 14:09:34 | admin | set | status: new -> ready |
2021-06-05 20:28:04 | admin | set | messages: + msg11866 |
2021-06-03 00:00:00 | admin | create |