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 
28   {
29     {
30       const std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
31       assert(tv.end() == std::ranges::next(tv.begin(), 4));
32       assert(std::ranges::next(tv.begin(), 4) == tv.end());
33     }
34 
35     {
36       std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
37       assert(tv.end() == std::ranges::next(tv.begin(), 4));
38       assert(std::ranges::next(tv.begin(), 4) == tv.end());
39     }
40   }
41 
42   {
43     std::ranges::take_view<MoveOnlyView> tvNonConst(MoveOnlyView{buffer}, 4);
44     const std::ranges::take_view<MoveOnlyView> tvConst(MoveOnlyView{buffer}, 4);
45     assert(tvNonConst.end() == std::ranges::next(tvConst.begin(), 4));
46     assert(std::ranges::next(tvConst.begin(), 4) == tvNonConst.end());
47   }
48 
49   return true;
50 }
51 
52 int main(int, char**) {
53   test();
54   static_assert(test());
55 
56   return 0;
57 }
58