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