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