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 // constexpr auto begin() 14 // requires (!(simple-view<V> && 15 // random_access_range<const V> && sized_range<const V>)); 16 // constexpr auto begin() const 17 // requires random_access_range<const V> && sized_range<const V>; 18 19 #include <ranges> 20 21 #include "test_macros.h" 22 #include "types.h" 23 24 template<class T> 25 concept BeginInvocable = requires(std::ranges::drop_view<T> t) { t.begin(); }; 26 27 constexpr bool test() { 28 // random_access_range<const V> && sized_range<const V> 29 std::ranges::drop_view dropView1(MoveOnlyView(), 4); 30 assert(dropView1.begin() == globalBuff + 4); 31 32 // !random_access_range<const V> 33 std::ranges::drop_view dropView2(ForwardView(), 4); 34 assert(dropView2.begin().base() == globalBuff + 4); 35 36 // !random_access_range<const V> 37 std::ranges::drop_view dropView3(InputView(), 4); 38 assert(dropView3.begin().base() == globalBuff + 4); 39 40 // random_access_range<const V> && sized_range<const V> 41 std::ranges::drop_view dropView4(MoveOnlyView(), 8); 42 assert(dropView4.begin() == globalBuff + 8); 43 44 // random_access_range<const V> && sized_range<const V> 45 std::ranges::drop_view dropView5(MoveOnlyView(), 0); 46 assert(dropView5.begin() == globalBuff); 47 48 // random_access_range<const V> && sized_range<const V> 49 const std::ranges::drop_view dropView6(MoveOnlyView(), 0); 50 assert(dropView6.begin() == globalBuff); 51 52 // random_access_range<const V> && sized_range<const V> 53 std::ranges::drop_view dropView7(MoveOnlyView(), 10); 54 assert(dropView7.begin() == globalBuff + 8); 55 56 CountedView view8; 57 std::ranges::drop_view dropView8(view8, 5); 58 assert(dropView8.begin().base().base() == globalBuff + 5); 59 assert(dropView8.begin().stride_count() == 5); 60 assert(dropView8.begin().base().base() == globalBuff + 5); 61 assert(dropView8.begin().stride_count() == 5); 62 63 static_assert(!BeginInvocable<const ForwardView>); 64 65 return true; 66 } 67 68 int main(int, char**) { 69 test(); 70 static_assert(test()); 71 72 return 0; 73 } 74