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-no-concepts
11 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
12 
13 // sentinel() = default;
14 // constexpr explicit sentinel(sentinel_t<Base> end);
15 // constexpr sentinel(sentinel<!Const> s)
16 //   requires Const && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
17 
18 #include <ranges>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 #include "test_iterators.h"
23 #include "../types.h"
24 
25 constexpr bool test() {
26   int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8};
27   auto sw = sentinel_wrapper<int *>(buffer + 8); // Note: not 4, but that's OK.
28 
29   {
30     const std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
31     assert(tv.end().base().base() == sw.base());
32     ASSERT_SAME_TYPE(decltype(tv.end().base()), sentinel_wrapper<int *>);
33   }
34 
35   {
36     std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
37     assert(tv.end().base().base() == sw.base());
38     ASSERT_SAME_TYPE(decltype(tv.end().base()), sentinel_wrapper<int *>);
39   }
40 
41   return true;
42 }
43 
44 int main(int, char**) {
45   test();
46   static_assert(test());
47 
48   return 0;
49 }
50