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 //===----------------------------------------------------------------------===//
14 // const_iterator begin() const;
16 // const_iterator end() const;
18 // reverse_iterator rbegin();
19 // const_reverse_iterator rbegin() const;
20 // reverse_iterator rend();
21 // const_reverse_iterator rend() const;
23 // const_iterator cbegin() const;
24 // const_iterator cend() const;
25 // const_reverse_iterator crbegin() const;
26 // const_reverse_iterator crend() const;
32 #include "test_macros.h"
33 #include "min_allocator.h"
66 std::set
<int> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
67 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
68 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
69 std::set
<int>::iterator i
;
71 std::set
<int>::const_iterator k
= i
;
73 for (int j
= 1; j
<= static_cast<int>(m
.size()); ++j
, ++i
)
76 for (int j
= static_cast<int>(m
.size()); j
>= 1; --j
) {
80 assert(i
== m
.begin());
111 const std::set
<int> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
112 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
113 assert(static_cast<std::size_t>(std::distance(m
.cbegin(), m
.cend())) == m
.size());
114 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
115 assert(static_cast<std::size_t>(std::distance(m
.crbegin(), m
.crend())) == m
.size());
116 std::set
<int>::const_iterator i
;
118 for (int j
= 1; j
<= static_cast<int>(m
.size()); ++j
, ++i
)
120 assert(i
== m
.end());
121 for (int j
= static_cast<int>(m
.size()); j
>= 1; --j
) {
125 assert(i
== m
.begin());
127 #if TEST_STD_VER >= 11
157 std::set
<int, std::less
<int>, min_allocator
<int>> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
158 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
159 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
160 std::set
<int, std::less
<int>, min_allocator
<int>>::iterator i
;
162 std::set
<int, std::less
<int>, min_allocator
<int>>::const_iterator k
= i
;
164 for (int j
= 1; j
<= static_cast<int>(m
.size()); ++j
, ++i
)
166 assert(i
== m
.end());
167 for (int j
= static_cast<int>(m
.size()); j
>= 1; --j
) {
171 assert(i
== m
.begin());
202 const std::set
<int, std::less
<int>, min_allocator
<int>> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
203 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
204 assert(static_cast<std::size_t>(std::distance(m
.cbegin(), m
.cend())) == m
.size());
205 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
206 assert(static_cast<std::size_t>(std::distance(m
.crbegin(), m
.crend())) == m
.size());
207 std::set
<int, std::less
<int>, min_allocator
<int>>::const_iterator i
;
209 for (int j
= 1; j
<= static_cast<int>(m
.size()); ++j
, ++i
)
211 assert(i
== m
.end());
212 for (int j
= static_cast<int>(m
.size()); j
>= 1; --j
) {
216 assert(i
== m
.begin());
219 #if TEST_STD_VER > 11
221 typedef std::set
<int> C
;
222 C::iterator ii1
{}, ii2
{};
223 C::iterator ii4
= ii1
;
224 C::const_iterator cii
{};
225 assert ( ii1
== ii2
);
226 assert ( ii1
== ii4
);
228 assert (!(ii1
!= ii2
));
230 assert ( (ii1
== cii
));
231 assert ( (cii
== ii1
));
232 assert (!(ii1
!= cii
));
233 assert (!(cii
!= ii1
));