Created on 2021-11-29.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to N4901.
Modify [view.interface.general], class template view_interface synopsis, as indicated:
[…] constexpr auto size() requires forward_range<D> && sized_sentinel_for<sentinel_t<D>, iterator_t<D>> { return to-unsigned-like(ranges::end(derived()) - ranges::begin(derived())); } constexpr auto size() const requires forward_range<const D> && sized_sentinel_for<sentinel_t<const D>, iterator_t<const D>> { return to-unsigned-like(ranges::end(derived()) - ranges::begin(derived())); } […]
[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]
[ 2022-09-23; Reflector poll ]
Set status to Tentatively Ready after five votes in favour during reflector poll in July 2022.
[ 2022-06-22; Reflector poll ]
LEWG poll approved the proposed resolution
[ 2022-01-30; Reflector poll ]
Set priority to 3 after reflector poll.
According to [view.interface.general], view_interface::size returns the difference between the sentinel and the beginning iterator, which always has a signed-integer-like type. However, IIUC the decision that a size member function should return an unsigned type by default was made when adopting P1227R2, and the relative changes of the ranges library were done in P1523R1. I don't know why view_interface::size was unchanged, while ranges::size returns an unsigned type in similar situations ([range.prim.size] (2.5)).
If we want to change views_interface::size to return an unsigned type, the both overloads should be changed as below:constexpr auto size() requires forward_range<D> && sized_sentinel_for<sentinel_t<D>, iterator_t<D>> { return to-unsigned-like(ranges::end(derived()) - ranges::begin(derived())); } constexpr auto size() const requires forward_range<const D> && sized_sentinel_for<sentinel_t<const D>, iterator_t<const D>> { return to-unsigned-like(ranges::end(derived()) - ranges::begin(derived())); }
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2022-11-17 00:42:33 | admin | set | messages: + msg13052 |
2022-11-17 00:42:33 | admin | set | status: voting -> wp |
2022-11-08 03:46:49 | admin | set | status: ready -> voting |
2022-09-23 14:31:54 | admin | set | messages: + msg12782 |
2022-09-23 14:31:54 | admin | set | messages: + msg12781 |
2022-09-23 14:31:54 | admin | set | status: lewg -> ready |
2022-01-30 17:05:36 | admin | set | messages: + msg12322 |
2022-01-30 17:05:36 | admin | set | status: new -> lewg |
2021-12-04 13:44:55 | admin | set | messages: + msg12240 |
2021-11-29 00:00:00 | admin | create |