brintos

brintos / llvm-project-archived public Read only

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