[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 / dereference.pass.cpp
blob292c6da9a7733e0032eee3ee23f5bac2c3ab7dac
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 // reference 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
20 #include <iterator>
21 #include <cassert>
23 #include "test_macros.h"
25 class A
27 int data_;
28 public:
29 A() : data_(1) {}
30 A(const A&) = default;
31 A& operator=(const A&) = default;
32 ~A() {data_ = -1;}
34 friend bool operator==(const A& x, const A& y)
35 {return x.data_ == y.data_;}
38 template <class It>
39 void
40 test(It i, typename std::iterator_traits<It>::value_type x)
42 std::reverse_iterator<It> r(i);
43 assert(*r == x);
46 int main(int, char**)
48 A a;
49 test(&a+1, A());
51 #if TEST_STD_VER > 14
53 constexpr const char *p = "123456789";
54 typedef std::reverse_iterator<const char *> RI;
55 constexpr RI it1 = std::make_reverse_iterator(p+1);
56 constexpr RI it2 = std::make_reverse_iterator(p+2);
57 static_assert(*it1 == p[0], "");
58 static_assert(*it2 == p[1], "");
60 #endif
62 return 0;