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::multiset
<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::multiset
<int>::iterator i
;
71 std::multiset
<int>::const_iterator k
= i
;
73 for (int j
= 1; j
<= 8; ++j
)
74 for (int n
= 0; n
< 3; ++n
, ++i
)
77 for (int j
= 8; j
>= 1; --j
)
78 for (int n
= 0; n
< 3; ++n
) {
82 assert(i
== m
.begin());
113 const std::multiset
<int> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
114 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
115 assert(static_cast<std::size_t>(std::distance(m
.cbegin(), m
.cend())) == m
.size());
116 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
117 assert(static_cast<std::size_t>(std::distance(m
.crbegin(), m
.crend())) == m
.size());
118 std::multiset
<int>::const_iterator i
;
120 for (int j
= 1; j
<= 8; ++j
)
121 for (int k
= 0; k
< 3; ++k
, ++i
)
123 assert(i
== m
.end());
124 for (int j
= 8; j
>= 1; --j
)
125 for (int k
= 0; k
< 3; ++k
) {
129 assert(i
== m
.begin());
131 #if TEST_STD_VER >= 11
161 std::multiset
<int, std::less
<int>, min_allocator
<int>> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
162 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
163 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
164 std::multiset
<int, std::less
<int>, min_allocator
<int>>::iterator i
;
166 std::multiset
<int, std::less
<int>, min_allocator
<int>>::const_iterator k
= i
;
168 for (int j
= 1; j
<= 8; ++j
)
169 for (int n
= 0; n
< 3; ++n
, ++i
)
171 assert(i
== m
.end());
172 for (int j
= 8; j
>= 1; --j
)
173 for (int n
= 0; n
< 3; ++n
) {
177 assert(i
== m
.begin());
208 const std::multiset
<int, std::less
<int>, min_allocator
<int>> m(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]));
209 assert(static_cast<std::size_t>(std::distance(m
.begin(), m
.end())) == m
.size());
210 assert(static_cast<std::size_t>(std::distance(m
.cbegin(), m
.cend())) == m
.size());
211 assert(static_cast<std::size_t>(std::distance(m
.rbegin(), m
.rend())) == m
.size());
212 assert(static_cast<std::size_t>(std::distance(m
.crbegin(), m
.crend())) == m
.size());
213 std::multiset
<int, std::less
<int>, min_allocator
<int>>::const_iterator i
;
215 for (int j
= 1; j
<= 8; ++j
)
216 for (int k
= 0; k
< 3; ++k
, ++i
)
218 assert(i
== m
.end());
219 for (int j
= 8; j
>= 1; --j
)
220 for (int k
= 0; k
< 3; ++k
) {
224 assert(i
== m
.begin());
227 #if TEST_STD_VER > 11
229 typedef std::multiset
<int> C
;
230 C::iterator ii1
{}, ii2
{};
231 C::iterator ii4
= ii1
;
232 C::const_iterator cii
{};
233 assert ( ii1
== ii2
);
234 assert ( ii1
== ii4
);
236 assert (!(ii1
!= ii2
));
238 assert ( (ii1
== cii
));
239 assert ( (cii
== ii1
));
240 assert (!(ii1
!= cii
));
241 assert (!(cii
!= ii1
));