namespace std::ranges {
template<auto> struct require-constant;
template<class R>
concept tiny-range =
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>> {
private:
V base_ = V();
Pattern pattern_ = Pattern();
non-propagating-cache<iterator_t<V>> current_;
template<bool> struct outer-iterator;
template<bool> struct inner-iterator;
public:
lazy_split_view()
requires default_initializable<V> && default_initializable<Pattern> = default;
constexpr explicit lazy_split_view(V base, Pattern pattern);
template<input_range R>
requires constructible_from<V, views::all_t<R>> &&
constructible_from<Pattern, single_view<range_value_t<R>>>
constexpr explicit lazy_split_view(R&& r, range_value_t<R> e);
constexpr V base() const & requires copy_constructible<V> { return base_; }
constexpr V base() && { return std::move(base_); }
constexpr auto begin() {
if constexpr (forward_range<V>) {
return outer-iterator<simple-view<V> && simple-view<Pattern>>
{*this, ranges::begin(base_)};
} else {
current_ = ranges::begin(base_);
return outer-iterator<false>{*this};
}
}
constexpr auto begin() const requires forward_range<V> && forward_range<const V> {
return outer-iterator<true>{*this, ranges::begin(base_)};
}
constexpr auto end() requires forward_range<V> && common_range<V> {
return outer-iterator<simple-view<V> && simple-view<Pattern>>
{*this, ranges::end(base_)};
}
constexpr auto end() const {
if constexpr (forward_range<V> && forward_range<const V> && common_range<const V>)
return outer-iterator<true>{*this, ranges::end(base_)};
else
return default_sentinel;
}
};
template<class R, class P>
lazy_split_view(R&&, P&&) -> lazy_split_view<views::all_t<R>, views::all_t<P>>;
template<input_range R>
lazy_split_view(R&&, range_value_t<R>)
-> lazy_split_view<views::all_t<R>, single_view<range_value_t<R>>>;
}
constexpr explicit lazy_split_view(V base, Pattern pattern);
Effects: Initializes
base_ with
std::move(base), and
pattern_ with
std::move(pattern). Effects: Initializes
base_ with
views::all(std::forward<R>(r)), and
pattern_ with
views::
single(std::move(e)).