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