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, c++20
10 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
11 
12 // sentinel() = default;
13 
14 #include <cassert>
15 #include <ranges>
16 #include <tuple>
17 
18 struct PODSentinel {
19   bool b; // deliberately uninitialised
20 
operator ==(int *,const PODSentinel & s)21   friend constexpr bool operator==(int*, const PODSentinel& s) { return s.b; }
22 };
23 
24 struct Range : std::ranges::view_base {
25   int* begin() const;
26   PODSentinel end();
27 };
28 
test()29 constexpr bool test() {
30   {
31     using R = std::ranges::zip_view<Range>;
32     using Sentinel = std::ranges::sentinel_t<R>;
33     static_assert(!std::is_same_v<Sentinel, std::ranges::iterator_t<R>>);
34 
35     std::ranges::iterator_t<R> it;
36 
37     Sentinel s1;
38     assert(it != s1); // PODSentinel.b is initialised to false
39 
40     Sentinel s2 = {};
41     assert(it != s2); // PODSentinel.b is initialised to false
42   }
43   return true;
44 }
45 
main(int,char **)46 int main(int, char**) {
47   test();
48   static_assert(test());
49 
50   return 0;
51 }
52