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