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 // std::ranges::lazy_split_view::outer-iterator::value_type::end() 13 14 #include <ranges> 15 16 #include <cassert> 17 #include "../types.h" 18 19 constexpr bool test() { 20 // `View` is a forward range. 21 { 22 CopyableView input("a"); 23 24 // Non-const. 25 { 26 SplitViewCopyable v(input, "b"); 27 auto val = *v.begin(); 28 29 static_assert(std::same_as<decltype(val.end()), std::default_sentinel_t>); 30 static_assert(noexcept(val.end())); 31 [[maybe_unused]] auto e = val.end(); 32 } 33 34 // Const. 35 { 36 SplitViewCopyable v(input, "b"); 37 const auto val = *v.begin(); 38 39 static_assert(std::same_as<decltype(val.end()), std::default_sentinel_t>); 40 static_assert(noexcept(val.end())); 41 [[maybe_unused]] auto e = val.end(); 42 } 43 } 44 45 // `View` is an input range. 46 { 47 InputView input("a"); 48 49 // Non-const. 50 { 51 SplitViewInput v(input, 'b'); 52 auto val = *v.begin(); 53 54 static_assert(std::same_as<decltype(val.end()), std::default_sentinel_t>); 55 static_assert(noexcept(val.end())); 56 [[maybe_unused]] auto e = val.end(); 57 } 58 59 // Const. 60 { 61 SplitViewInput v(input, 'b'); 62 const auto val = *v.begin(); 63 64 static_assert(std::same_as<decltype(val.end()), std::default_sentinel_t>); 65 static_assert(noexcept(val.end())); 66 [[maybe_unused]] auto e = val.end(); 67 } 68 } 69 70 return true; 71 } 72 73 int main(int, char**) { 74 assert(test()); 75 static_assert(test()); 76 77 return 0; 78 } 79