Created on 2023-01-07.00:00:00 last changed 21 months ago
Proposed resolution:
This wording is relative to N4917.
Modify [range.lazy.split.view] as indicated:
namespace std::ranges {template<auto> struct require-constant; // exposition onlytemplate<class R> concept tiny-range = // exposition only sized_range<R> && requires { typename require-constant<remove_reference_t<R>::size()>; } && (remove_reference_t<R>::size() <= 1);template<input_range V, forward_range Pattern> requires view<V> && view<Pattern> && indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> && (forward_range<V> || tiny-range<Pattern>) class lazy_split_view : public view_interface<lazy_split_view<V, Pattern>> { […] }; […] }template<class R> concept tiny-range = // exposition only sized_range<R> && requires { requires bool_constant<(remove_reference_t<R>::size() <= 1)>::value; };-?- Given an lvalue r of type remove_reference_t<R>, R models tiny-range only if ranges::size(r) is evaluated by remove_reference_t<R>::size().
constexpr lazy_split_view(V base, Pattern pattern);-1- Effects: : Initializes base_ with std::move(base), and pattern_ with std::move(pattern).
[ 2023-02-01; Reflector poll ]
Set priority to 4 after reflector poll. Only matters for pathological types. Maybe use requires bool_constant<ranges::size(r) <= 1>.
Currently, lazy_split_view supports input range when the element of the pattern is less than or equal to 1. In order to ensure this condition at compile time, tiny-range constrains the type R to model sized_range and requires (remove_reference_t<R>::size() <= 1) to be a constant expression.
However, modeling a sized_range does not guarantee that ranges::size will be evaluated by R::size(). For example, when disable_sized_range<R> is specialized to true or R::size() returns a non-integer-like type, ranges::size can still compute the size by subtracting the iterator-sentinel pair when both satisfy sized_sentinel_for. Since the lazy_split_view's iterator uses R::size() to get the constant value of the pattern, we must ensure that this is indeed how ranges::size is calculated. Also, I think we can simplify tiny-range with bool_constant in a way similar to LWG 3150, which removes the introduction of require-constant.History | |||
---|---|---|---|
Date | User | Action | Args |
2023-02-01 20:48:23 | admin | set | messages: + msg13252 |
2023-01-14 12:28:11 | admin | set | messages: + msg13206 |
2023-01-07 00:00:00 | admin | create |