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

source code of libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/ctor.default.pass.cpp