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 outer-iterator::value-type outer-iterator::operator*() const;
12
13 #include <ranges>
14
15 #include <algorithm>
16 #include <cassert>
17 #include <string>
18 #include <string_view>
19 #include <type_traits>
20 #include "../types.h"
21
22 template <class View, class Separator>
test_one(Separator sep)23 constexpr void test_one(Separator sep) {
24 using namespace std::string_literals;
25 using namespace std::string_view_literals;
26
27 View v("abc def ghi"sv, sep);
28
29 // Non-const iterator.
30 {
31 auto i = v.begin();
32 static_assert(!std::is_reference_v<decltype(*i)>);
33 assert(std::ranges::equal(*i, "abc"s));
34 assert(std::ranges::equal(*(++i), "def"s));
35 assert(std::ranges::equal(*(++i), "ghi"s));
36 }
37
38 // Const iterator.
39 {
40 const auto ci = v.begin();
41 static_assert(!std::is_reference_v<decltype(*ci)>);
42 assert(std::ranges::equal(*ci, "abc"s));
43 }
44 }
45
test()46 constexpr bool test() {
47 // `View` is a forward range.
48 test_one<SplitViewDiff>(" ");
49 test_one<SplitViewInput>(' ');
50
51 return true;
52 }
53
main(int,char **)54 int main(int, char**) {
55 test();
56 static_assert(test());
57
58 return 0;
59 }
60