xref: /llvm-project/libcxx/test/std/ranges/range.adaptors/range.take/range.take.sentinel/base.pass.cpp (revision 0b46606ca5b52aa515c5359ed6f24fb18d825b50)
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 // constexpr sentinel_t<Base> base() const;
12 
13 #include <ranges>
14 #include <cassert>
15 
16 #include "test_macros.h"
17 #include "test_iterators.h"
18 #include "../types.h"
19 
test()20 constexpr bool test() {
21   int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8};
22   {
23     std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView(buffer), 4);
24     std::same_as<sentinel_wrapper<int*>> auto sw1 = tv.end().base();
25     assert(base(sw1) == buffer + 8);
26     std::same_as<sentinel_wrapper<int*>> auto sw2 = std::as_const(tv).end().base();
27     assert(base(sw2) == buffer + 8);
28   }
29   return true;
30 }
31 
main(int,char **)32 int main(int, char**) {
33   test();
34   static_assert(test());
35 
36   return 0;
37 }
38