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& outer-iterator::operator++(); 13 // constexpr decltype(auto) outer-iterator::operator++(int); 14 15 // Note that corner cases are tested in `range.lazy.split/general.pass.cpp`. 16 17 #include <ranges> 18 19 #include <algorithm> 20 #include <string_view> 21 #include "../small_string.h" 22 #include "../types.h" 23 24 constexpr bool test() { 25 // Can call `outer-iterator::operator++`; `View` is a forward range. 26 { 27 SplitViewForward v("abc def ghi", " "); 28 29 // ++i 30 { 31 auto i = v.begin(); 32 assert(*i == "abc"_str); 33 34 decltype(auto) i2 = ++i; 35 static_assert(std::is_lvalue_reference_v<decltype(i2)>); 36 assert(&i2 == &i); 37 assert(*i2 == "def"_str); 38 } 39 40 // i++ 41 { 42 auto i = v.begin(); 43 assert(*i == "abc"_str); 44 45 decltype(auto) i2 = i++; 46 static_assert(!std::is_reference_v<decltype(i2)>); 47 assert(*i2 == "abc"_str); 48 assert(*i == "def"_str); 49 } 50 } 51 52 // Can call `outer-iterator::operator++`; `View` is an input range. 53 { 54 SplitViewInput v("abc def ghi", ' '); 55 56 // ++i 57 { 58 auto i = v.begin(); 59 assert(*i == "abc"_str); 60 61 decltype(auto) i2 = ++i; 62 static_assert(std::is_lvalue_reference_v<decltype(i2)>); 63 assert(&i2 == &i); 64 assert(*i2 == "def"_str); 65 } 66 67 // i++ 68 { 69 auto i = v.begin(); 70 assert(*i == "abc"_str); 71 72 static_assert(std::is_void_v<decltype(i++)>); 73 i++; 74 assert(*i == "def"_str); 75 } 76 } 77 78 return true; 79 } 80 81 int main(int, char**) { 82 test(); 83 static_assert(test()); 84 85 return 0; 86 } 87