1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11// template<forward_range V, forward_range Pattern>
12// requires view<V> && view<Pattern> &&
13// indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to>
14// class split_view;
15
16#include <ranges>
17
18#include "test_macros.h"
19#include "test_iterators.h"
20
21template <class It>
22using Range = std::ranges::subrange<It, sentinel_wrapper<It>>;
23
24template <class View, class Pattern>
25concept HasSplitView = requires { typename std::ranges::split_view<View, Pattern>; };
26
27static_assert(HasSplitView<Range<int*>, Range<int*>>);
28
29// !forward_range<V>
30static_assert(!HasSplitView<Range<cpp20_input_iterator<int*>>, Range<int*>>);
31
32// !forward_range<Pattern>
33static_assert(!HasSplitView<Range<int*>, Range<cpp20_input_iterator<int*>>>);
34
35struct NotAView {
36 int* begin() const;
37 int* end() const;
38};
39
40// !view<V>
41static_assert(!HasSplitView<NotAView, Range<int*>>);
42
43// !view<Pattern>
44static_assert(!HasSplitView<Range<int*>, NotAView>);
45
46// indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to
47struct Foo {};
48static_assert(!HasSplitView<Range<int*>, Range<Foo*>>);
49

source code of libcxx/test/std/ranges/range.adaptors/range.split/constraints.compile.pass.cpp