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