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