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 //===----------------------------------------------------------------------===//
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_multiset
15 // iterator erase(const_iterator first, const_iterator last)
17 #include <unordered_set>
21 #include "test_macros.h"
22 #include "min_allocator.h"
27 typedef std::unordered_multiset
<int> C
;
38 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
39 C::const_iterator i
= c
.find(2);
40 C::const_iterator j
= std::next(i
, 2);
41 C::iterator k
= c
.erase(i
, i
);
43 assert(c
.size() == 6);
44 assert(c
.count(1) == 2);
45 assert(c
.count(2) == 2);
46 assert(c
.count(3) == 1);
47 assert(c
.count(4) == 1);
50 assert(c
.size() == 4);
51 assert(c
.count(1) == 2);
52 assert(c
.count(3) == 1);
53 assert(c
.count(4) == 1);
55 k
= c
.erase(c
.cbegin(), c
.cend());
56 assert(c
.size() == 0);
59 #if TEST_STD_VER >= 11
61 typedef std::unordered_multiset
<int, std::hash
<int>,
62 std::equal_to
<int>, min_allocator
<int>> C
;
73 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
74 C::const_iterator i
= c
.find(2);
75 C::const_iterator j
= std::next(i
, 2);
76 C::iterator k
= c
.erase(i
, i
);
78 assert(c
.size() == 6);
79 assert(c
.count(1) == 2);
80 assert(c
.count(2) == 2);
81 assert(c
.count(3) == 1);
82 assert(c
.count(4) == 1);
85 assert(c
.size() == 4);
86 assert(c
.count(1) == 2);
87 assert(c
.count(3) == 1);
88 assert(c
.count(4) == 1);
90 k
= c
.erase(c
.cbegin(), c
.cend());
91 assert(c
.size() == 0);