Date
2022-03-23.00:00:00
Message id
12410

Content

In lazy_split_view, the deduction guide that accepts two arbitrary types wraps the arguments in views::all_t ([range.lazy.split.view]):

template<class R, class P>
  lazy_split_view(R&&, P&&) -> lazy_split_view<views::all_t<R>, views::all_t<P>>;

When trying to use an input_range as the input, lazy_split_view requires the pattern type to satisfy the exposition-only concept tiny-range. Trying to use CTAD with an input_range and a tiny-range as arguments results in a compiler error, as demonstrated in the demo link:

// Assuming `InputRange` and `TinyRange` are valid types satisfying the
// corresponding concepts.
std::ranges::lazy_split_view view{InputRange(), TinyRange()}; // Compiler error

The underlying reason is that tiny-range requires the given type to contain a static member function size() that returns a number <=1 ([range.lazy.split.view]):

template<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);

However, when given a range, views::all_t wraps the type in a ranges::owning_view. owning_view doesn't satisfy tiny-range for any template parameter because it never contains the static size() function required by the concept.

A general resolution might be modifying owning_view so that it satisfies tiny-range when the given type is a tiny-range (that would require moving the tiny-range concept from [range.lazy.split.view] to [range.utility.helpers]). A more localized solution can be to change the deduction guide in lazy_split_view to avoid wrapping a type satisfying tiny-range in views::all_t.