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 // constexpr W operator[](difference_type n) const 13 // requires advanceable<W>; 14 15 #include <ranges> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "../types.h" 20 21 template<class T> testType()22constexpr void testType() { 23 { 24 std::ranges::iota_view<T> io(T(0)); 25 auto iter = io.begin(); 26 for (int i = 0; i < 100; ++i) 27 assert(iter[i] == T(i)); 28 } 29 { 30 std::ranges::iota_view<T> io(T(10)); 31 auto iter = io.begin(); 32 for (int i = 0; i < 100; ++i) 33 assert(iter[i] == T(i + 10)); 34 } 35 { 36 const std::ranges::iota_view<T> io(T(0)); 37 auto iter = io.begin(); 38 for (int i = 0; i < 100; ++i) 39 assert(iter[i] == T(i)); 40 } 41 { 42 const std::ranges::iota_view<T> io(T(10)); 43 auto iter = io.begin(); 44 for (int i = 0; i < 100; ++i) 45 assert(iter[i] == T(i + 10)); 46 } 47 } 48 test()49constexpr bool test() { 50 testType<SomeInt>(); 51 testType<signed long>(); 52 testType<unsigned long>(); 53 testType<int>(); 54 testType<unsigned>(); 55 testType<short>(); 56 testType<unsigned short>(); 57 58 return true; 59 } 60 main(int,char **)61int main(int, char**) { 62 test(); 63 static_assert(test()); 64 65 return 0; 66 } 67