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 <class R, class P> |
12 | // split_view(R&&, P&&) -> split_view<views::all_t<R>, views::all_t<P>>; |
13 | // |
14 | // template <input_range R> |
15 | // split_view(R&&, range_value_t<R>) -> split_view<views::all_t<R>, single_view<range_value_t<R>>>; |
16 | |
17 | #include <concepts> |
18 | #include <ranges> |
19 | #include <type_traits> |
20 | #include <utility> |
21 | |
22 | struct Container { |
23 | int* begin() const; |
24 | int* end() const; |
25 | }; |
26 | |
27 | struct View : std::ranges::view_base { |
28 | int* begin() const; |
29 | int* end() const; |
30 | }; |
31 | |
32 | template <class I1, class I2, class ExpectedView, class ExpectedPattern> |
33 | constexpr void test() { |
34 | static_assert(std::is_same_v<decltype(std::ranges::split_view(std::declval<I1>(), std::declval<I2>())), |
35 | std::ranges::split_view<ExpectedView, ExpectedPattern>>); |
36 | } |
37 | |
38 | constexpr void testCtad() { |
39 | // (Range, Pattern) |
40 | test<View, View, View, View>(); |
41 | test<Container&, Container&, std::ranges::ref_view<Container>, std::ranges::ref_view<Container>>(); |
42 | test<Container&&, Container&&, std::ranges::owning_view<Container>, std::ranges::owning_view<Container>>(); |
43 | |
44 | // (Range, RangeElement) |
45 | test<Container&, int, std::ranges::ref_view<Container>, std::ranges::single_view<int>>(); |
46 | test<View, int, View, std::ranges::single_view<int>>(); |
47 | |
48 | // (Range, RangeElement) with implicit conversion. |
49 | test<Container&, bool, std::ranges::ref_view<Container>, std::ranges::single_view<int>>(); |
50 | test<View, bool, View, std::ranges::single_view<int>>(); |
51 | } |
52 | |