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 | |
21 | template <class It> |
22 | using Range = std::ranges::subrange<It, sentinel_wrapper<It>>; |
23 | |
24 | template <class View, class Pattern> |
25 | concept HasSplitView = requires { typename std::ranges::split_view<View, Pattern>; }; |
26 | |
27 | static_assert(HasSplitView<Range<int*>, Range<int*>>); |
28 | |
29 | // !forward_range<V> |
30 | static_assert(!HasSplitView<Range<cpp20_input_iterator<int*>>, Range<int*>>); |
31 | |
32 | // !forward_range<Pattern> |
33 | static_assert(!HasSplitView<Range<int*>, Range<cpp20_input_iterator<int*>>>); |
34 | |
35 | struct NotAView { |
36 | int* begin() const; |
37 | int* end() const; |
38 | }; |
39 | |
40 | // !view<V> |
41 | static_assert(!HasSplitView<NotAView, Range<int*>>); |
42 | |
43 | // !view<Pattern> |
44 | static_assert(!HasSplitView<Range<int*>, NotAView>); |
45 | |
46 | // indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to |
47 | struct Foo {}; |
48 | static_assert(!HasSplitView<Range<int*>, Range<Foo*>>); |
49 | |