brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 5c831f3 Raw
75 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// friend constexpr bool operator==(const iterator& x, const iterator& y);12//          requires ref-is-glvalue && forward_range<Base> &&13//                   equality_comparable<iterator_t<range_reference_t<Base>>>;14 15#include <cassert>16#include <ranges>17 18#include "../types.h"19 20constexpr bool test() {21  int buffer[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};22  {23    std::ranges::join_view jv(buffer);24    auto iter1 = jv.begin();25    auto iter2 = jv.begin();26    assert(iter1 == iter2);27    iter1++;28    assert(iter1 != iter2);29    iter2++;30    assert(iter1 == iter2);31 32    assert(jv.begin() == std::as_const(jv).begin());33  }34 35  {36    // !ref-is-glvalue37    BidiCommonInner inners[2] = {buffer[0], buffer[1]};38    InnerRValue<BidiCommonOuter<BidiCommonInner>> outer{inners};39    std::ranges::join_view jv(outer);40    auto iter = jv.begin();41    static_assert(!std::equality_comparable<decltype(iter)>);42  }43 44  {45    // !forward_range<Base>46    using Inner = BufferView<int*>;47    using Outer = BufferView<cpp20_input_iterator<Inner*>, sentinel_wrapper<cpp20_input_iterator<Inner*>>>;48    static_assert(!std::equality_comparable<std::ranges::iterator_t<Outer>>);49    Inner inners[2] = {buffer[0], buffer[1]};50    std::ranges::join_view jv(Outer{inners});51    auto iter = jv.begin();52    static_assert(!std::equality_comparable<decltype(iter)>);53  }54 55  {56    // !equality_comparable<iterator_t<range_reference_t<Base>>>;57    using Inner = BufferView<cpp20_input_iterator<int*>, sentinel_wrapper<cpp20_input_iterator<int*>>>;58    Inner inners[1] = {buffer[0]};59    std::ranges::join_view jv{inners};60    auto iter = jv.begin();61    static_assert(!std::equality_comparable<decltype(iter)>);62    auto const_iter = std::as_const(jv).begin();63    static_assert(!std::equality_comparable<decltype(const_iter)>);64  }65 66  return true;67}68 69int main(int, char**) {70  test();71  static_assert(test());72 73  return 0;74}75