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