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 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
11
12 // std::ranges::lazy_split_view::outer-iterator::value_type::begin()
13
14 #include <ranges>
15
16 #include <cassert>
17 #include "../types.h"
18
test()19 constexpr bool test() {
20 // `View` is a forward range.
21 {
22 CopyableView input("a");
23
24 // Non-const.
25 {
26 SplitViewCopyable v(input, "b");
27 auto val = *v.begin();
28 assert(val.begin().base() == input.begin());
29 }
30
31 // Const.
32 {
33 SplitViewCopyable v(input, "b");
34 const auto val = *v.begin();
35 assert(val.begin().base() == input.begin());
36 }
37 }
38
39 // `View` is an input range.
40 {
41 InputView input("a");
42
43 // Non-const.
44 {
45 SplitViewInput v(input, 'b');
46 auto val = *v.begin();
47 // Copies of `InputView` are independent and the iterators won't compare the same.
48 assert(*val.begin().base() == *input.begin());
49 }
50
51 // Const.
52 {
53 SplitViewInput v(input, 'b');
54 const auto val = *v.begin();
55 // Copies of `InputView` are independent and the iterators won't compare the same.
56 assert(*val.begin().base() == *input.begin());
57 }
58 }
59
60 return true;
61 }
62
main(int,char **)63 int main(int, char**) {
64 assert(test());
65 static_assert(test());
66
67 return 0;
68 }
69