[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / iterators / predef.iterators / reverse.iterators / reverse.iter.elem / arrow.pass.cpp
blob15d18d9145ef0c871d5b1b930f4c28a849f6548d
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 // pointer operator->() const; // constexpr in C++17
15 // Be sure to respect LWG 198:
16 // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
17 // LWG 198 was superseded by LWG 2360
18 // http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
21 #include <iterator>
22 #include <list>
23 #include <cassert>
25 #include "test_macros.h"
27 class A
29 int data_;
30 public:
31 A() : data_(1) {}
32 A(const A&) = default;
33 A& operator=(const A&) = default;
34 ~A() {data_ = -1;}
36 int get() const {return data_;}
38 friend bool operator==(const A& x, const A& y)
39 {return x.data_ == y.data_;}
42 template <class It>
43 void
44 test(It i, typename std::iterator_traits<It>::value_type x)
46 std::reverse_iterator<It> r(i);
47 assert(r->get() == x.get());
50 class B
52 int data_;
53 public:
54 B(int d=1) : data_(d) {}
55 B(const B&) = default;
56 B& operator=(const B&) = default;
57 ~B() {data_ = -1;}
59 int get() const {return data_;}
61 friend bool operator==(const B& x, const B& y)
62 {return x.data_ == y.data_;}
63 const B *operator&() const { return nullptr; }
64 B *operator&() { return nullptr; }
67 class C
69 int data_;
70 public:
71 TEST_CONSTEXPR C() : data_(1) {}
73 TEST_CONSTEXPR int get() const {return data_;}
75 friend TEST_CONSTEXPR bool operator==(const C& x, const C& y)
76 {return x.data_ == y.data_;}
79 TEST_CONSTEXPR C gC;
81 int main(int, char**)
83 A a;
84 test(&a+1, A());
87 std::list<B> l;
88 l.push_back(B(0));
89 l.push_back(B(1));
90 l.push_back(B(2));
93 std::list<B>::const_iterator i = l.begin();
94 assert ( i->get() == 0 ); ++i;
95 assert ( i->get() == 1 ); ++i;
96 assert ( i->get() == 2 ); ++i;
97 assert ( i == l.end ());
101 std::list<B>::const_reverse_iterator ri = l.rbegin();
102 assert ( ri->get() == 2 ); ++ri;
103 assert ( ri->get() == 1 ); ++ri;
104 assert ( ri->get() == 0 ); ++ri;
105 assert ( ri == l.rend ());
109 #if TEST_STD_VER > 14
111 typedef std::reverse_iterator<const C *> RI;
112 constexpr RI it1 = std::make_reverse_iterator(&gC+1);
114 static_assert(it1->get() == gC.get(), "");
116 #endif
118 ((void)gC);
121 return 0;