[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / unord / unord.multiset / erase_range.pass.cpp
blob954d3bc1f9ebc2c0b017b1b79864d1831e50bf1f
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 // <unordered_set>
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>
18 #include <cassert>
19 #include <iterator>
21 #include "test_macros.h"
22 #include "min_allocator.h"
24 int main(int, char**)
27 typedef std::unordered_multiset<int> C;
28 typedef int P;
29 P a[] =
31 P(1),
32 P(2),
33 P(3),
34 P(4),
35 P(1),
36 P(2)
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);
42 assert(k == 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);
49 k = c.erase(i, j);
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);
57 assert(k == c.end());
59 #if TEST_STD_VER >= 11
61 typedef std::unordered_multiset<int, std::hash<int>,
62 std::equal_to<int>, min_allocator<int>> C;
63 typedef int P;
64 P a[] =
66 P(1),
67 P(2),
68 P(3),
69 P(4),
70 P(1),
71 P(2)
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);
77 assert(k == 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);
84 k = c.erase(i, j);
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);
92 assert(k == c.end());
94 #endif
96 return 0;