Created on 2022-07-15.00:00:00 last changed 24 months ago
Proposed resolution:
This wording is relative to N4910.
Modify [range.chunk.view.input] as indicated:
constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>;-5- Effects: Equivalent to:
returnto-unsigned-like(div-ceil(ranges::sizedistance(base_), static_cast<decltype(ranges::size(base_))>(n_));
Modify [range.chunk.view.fwd] as indicated:
constexpr auto size() requires sized_range<V>; constexpr auto size() const requires sized_range<const V>;-3- Effects: Equivalent to:
returnto-unsigned-like(div-ceil(ranges::sizedistance(base_), static_cast<decltype(ranges::size(base_))>(n_));
[ 2022-11-30 LWG telecon. Status changed: Tentatively NAD → NAD. ]
[ 2022-08-23; Reflector poll: NAD (would need a paper for LEWG) ]
The "range_difference_t<const V> and range_difference_t<V> can be both valid but have different types" part is something I expect Mr. Carter's eventual paper to outlaw. The "preserve signedness" part is LEWG.
Currently, the Effects of chunk_view::size simply returns to-unsigned-like(div-ceil(ranges::distance(base_), n_)), where div-ceil is defined in [range.chunk.view.input] as:
template<class I> constexpr I div-ceil(I num, I denom) { // exposition only I r = num / denom; if (num % denom) ++r; return r; }
There are two problems here. First, for the const version of chunk_view::size, the types of ranges::distance(base_) and n_ are range_difference_t<const V> and range_difference_t<V> respectively, and the two parameters of div-ceil have the same type I. Given that the standard does not guarantee that V and const V must have the same difference_type, this makes the div-ceil's template deduction fail when the two are different.
Second, the standard does not guarantee that ranges::size must return an unsigned type, but here we use to-unsigned-like to unconditionally convert the return type of chunk_view::size to an unsigned type, which is inconsistent with the behavior of other range adaptors such as take_view and drop_view. We should try to preserve the characteristics of the range_size_t of the underlying range as much as possible.History | |||
---|---|---|---|
Date | User | Action | Args |
2022-11-30 17:59:24 | admin | set | messages: + msg13136 |
2022-08-23 15:00:26 | admin | set | messages: + msg12686 |
2022-08-23 15:00:26 | admin | set | status: new -> nad |
2022-07-16 17:46:58 | admin | set | messages: + msg12594 |
2022-07-15 00:00:00 | admin | create |