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 // constexpr decltype(auto) inner-iterator::operator*() const;
12
13 #include <ranges>
14
15 #include "../types.h"
16
test()17 constexpr bool test() {
18 // Can call `inner-iterator::operator*`; `View` is a forward range.
19 {
20 SplitViewDiff v("abc def", " ");
21 auto val = *v.begin();
22
23 // Non-const iterator.
24 {
25 auto i = val.begin();
26 static_assert(std::same_as<decltype(*i), char&>);
27 assert(*i == 'a');
28 assert(*(++i) == 'b');
29 assert(*(++i) == 'c');
30 }
31
32 // Const iterator.
33 {
34 const auto ci = val.begin();
35 static_assert(std::same_as<decltype(*ci), char&>);
36 assert(*ci == 'a');
37 }
38 }
39
40 // Can call `inner-iterator::operator*`; `View` is an input range.
41 {
42 SplitViewInput v("abc def", ' ');
43 auto val = *v.begin();
44
45 // Non-const iterator.
46 {
47 auto i = val.begin();
48 static_assert(std::same_as<decltype(*i), char&>);
49 assert(*i == 'a');
50 assert(*(++i) == 'b');
51 assert(*(++i) == 'c');
52 }
53
54 // Const iterator.
55 {
56 const auto ci = val.begin();
57 static_assert(std::same_as<decltype(*ci), char&>);
58 // Note: when the underlying range is an input range, `current` is stored in the `lazy_split_view` itself and
59 // shared between `inner-iterator`s. Consequently, incrementing one iterator effectively increments all of them.
60 assert(*ci == 'c');
61 }
62 }
63
64 return true;
65 }
66
main(int,char **)67 int main(int, char**) {
68 test();
69 static_assert(test());
70
71 return 0;
72 }
73