ssizeSection: 24.7 [iterator.range], 25.3.11 [range.prim.ssize] Status: New Submitter: Casey Carter Opened: 2024-12-13 Last modified: 2025-02-07
Priority: 3
View other active issues in [iterator.range].
View all other issues in [iterator.range].
View all issues with New status.
Discussion:
There exist range types R whose size is representable by neither ptrdiff_t nor
make-signed-like-t<ranges::range_size_t<R>>, specifically views::iota(size_t(0), size_t(-1)).
It's unfortunate that std::ssize and ranges::ssize produce a negative size for such ranges even when their
difference type is capable of representing their size (see demo).
Perhaps the ssize overloads should return
static_cast<common_type_t<ptrdiff_t, iter_difference_t<decltype(meow.begin())>>>(meow.size())
instead when the argument meow models range?
[2025-02-07; Reflector poll]
Set priority to 3 after reflector poll.
"The behaviour for Ranges regressed due to LWG 3403.
It might have been a mistake to broaden the domain of ranges::ssize to match
that of ranges::size. The latter includes some non-Range arguments to ease
the transition from std::size, but thjere was no existing body of pre-C++20
code calling std::ssize that needed a transition path."
Proposed resolution: