1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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
25 #include "test_macros.h"
32 A(const A
&) = default;
33 A
& operator=(const A
&) = default;
36 int get() const {return data_
;}
38 friend bool operator==(const A
& x
, const A
& y
)
39 {return x
.data_
== y
.data_
;}
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());
54 B(int d
=1) : data_(d
) {}
55 B(const B
&) = default;
56 B
& operator=(const B
&) = default;
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; }
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_
;}
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(), "");