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