[Flang] Add semantics checks for CrayPointer usage in DSA list (#123171)
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / reverse.iterators / reverse.iter.cmp / equal.pass.cpp
blob6fe575ebdd9a0d14c2921a2be60381f5830e40eb
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 //===----------------------------------------------------------------------===//
9 // <iterator>
11 // reverse_iterator
13 // template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
14 // requires HasEqualTo<Iter1, Iter2>
15 // bool operator==(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y); // constexpr since C++17
17 #include <iterator>
18 #include <cassert>
20 #include "test_macros.h"
21 #include "test_iterators.h"
23 template <class It>
24 TEST_CONSTEXPR_CXX17 void test(It l, It r, bool x) {
25 const std::reverse_iterator<It> r1(l);
26 const std::reverse_iterator<It> r2(r);
27 assert((r1 == r2) == x);
30 TEST_CONSTEXPR_CXX17 bool tests() {
31 const char* s = "1234567890";
32 test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), true);
33 test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), false);
34 test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
35 test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
36 #if TEST_STD_VER >= 20
37 test(cpp20_random_access_iterator<const char*>(s), cpp20_random_access_iterator<const char*>(s), true);
38 test(cpp20_random_access_iterator<const char*>(s), cpp20_random_access_iterator<const char*>(s + 1), false);
39 #endif
40 test(s, s, true);
41 test(s, s+1, false);
42 return true;
45 int main(int, char**) {
46 tests();
47 #if TEST_STD_VER > 14
48 static_assert(tests(), "");
49 #endif
50 return 0;