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 | // <iterator> |
10 | |
11 | // reverse_iterator |
12 | |
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 in C++17 |
16 | |
17 | #include <iterator> |
18 | #include <cassert> |
19 | |
20 | #include "test_macros.h" |
21 | #include "test_iterators.h" |
22 | |
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); |
28 | } |
29 | |
30 | TEST_CONSTEXPR_CXX17 bool tests() { |
31 | const char* s = "1234567890" ; |
32 | test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), false); |
33 | test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), true); |
34 | test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false); |
35 | test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true); |
36 | test(s, s, false); |
37 | test(s, s+1, true); |
38 | return true; |
39 | } |
40 | |
41 | int main(int, char**) { |
42 | tests(); |
43 | #if TEST_STD_VER > 14 |
44 | static_assert(tests(), "" ); |
45 | #endif |
46 | return 0; |
47 | } |
48 | |