Title
Domain of ranges::ssize(E) doesn't match ranges::size(E)
Status
new
Section
[range.prim.ssize]
Submitter
Jonathan Wakely

Created on 2019-02-19.00:00:00 last changed 3 months ago

Messages

Date: 2020-03-11.00:00:00

[ 2020-03-11 Issue Prioritization ]

Priority to 2 after reflector discussion.

Date: 2019-02-19.00:00:00

ranges::size(E) works with a non-range for which E.size() or size(E) is valid. But ranges::ssize(E) requires the type range_difference_t which requires ranges::begin(E) to be valid. This means there are types for which ranges::size(E) is valid but ranges::ssize(E) is not.

Casey's reaction to this is:

I believe we want ranges::ssize to work with any argument that ranges::size accepts. That suggest to me that we're going to need make-signed-like-t<T> after all, so we can "Let E be an expression, and let D be the wider of ptrdiff_t or decltype(ranges::size(E)). Then ranges::ssize(E) is expression-equivalent to static_cast<make-signed-like-t<D>>(ranges::size(E))." Although this wording is still slightly icky since D isn't a valid type when ranges::size(E) isn't a valid expression, I think it's an improvement?

History
Date User Action Args
2020-03-11 18:56:33adminsetmessages: + msg11161
2019-02-19 00:00:00admincreate