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 | //===----------------------------------------------------------------------===// |
8 | |
9 | // <unordered_set> |
10 | |
11 | // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, |
12 | // class Alloc = allocator<Value>> |
13 | // class unordered_multiset |
14 | |
15 | // iterator begin(); |
16 | // iterator end(); |
17 | // const_iterator begin() const; |
18 | // const_iterator end() const; |
19 | // const_iterator cbegin() const; |
20 | // const_iterator cend() const; |
21 | |
22 | #include <unordered_set> |
23 | #include <cassert> |
24 | #include <cstddef> |
25 | |
26 | #include "test_macros.h" |
27 | #include "min_allocator.h" |
28 | |
29 | int main(int, char**) |
30 | { |
31 | { |
32 | typedef std::unordered_multiset<int> C; |
33 | typedef int P; |
34 | P a[] = |
35 | { |
36 | P(1), |
37 | P(2), |
38 | P(3), |
39 | P(4), |
40 | P(1), |
41 | P(2) |
42 | }; |
43 | C c(a, a + sizeof(a)/sizeof(a[0])); |
44 | assert(c.bucket_count() >= 7); |
45 | assert(c.size() == 6); |
46 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
47 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
48 | C::iterator i; |
49 | } |
50 | { |
51 | typedef std::unordered_multiset<int> C; |
52 | typedef int P; |
53 | P a[] = |
54 | { |
55 | P(1), |
56 | P(2), |
57 | P(3), |
58 | P(4), |
59 | P(1), |
60 | P(2) |
61 | }; |
62 | const C c(a, a + sizeof(a)/sizeof(a[0])); |
63 | assert(c.bucket_count() >= 7); |
64 | assert(c.size() == 6); |
65 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
66 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
67 | C::const_iterator i; |
68 | } |
69 | #if TEST_STD_VER >= 11 |
70 | { |
71 | typedef std::unordered_multiset<int, std::hash<int>, |
72 | std::equal_to<int>, min_allocator<int>> C; |
73 | typedef int P; |
74 | P a[] = |
75 | { |
76 | P(1), |
77 | P(2), |
78 | P(3), |
79 | P(4), |
80 | P(1), |
81 | P(2) |
82 | }; |
83 | C c(a, a + sizeof(a)/sizeof(a[0])); |
84 | assert(c.bucket_count() >= 7); |
85 | assert(c.size() == 6); |
86 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
87 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
88 | C::iterator i; |
89 | } |
90 | { |
91 | typedef std::unordered_multiset<int, std::hash<int>, |
92 | std::equal_to<int>, min_allocator<int>> C; |
93 | typedef int P; |
94 | P a[] = |
95 | { |
96 | P(1), |
97 | P(2), |
98 | P(3), |
99 | P(4), |
100 | P(1), |
101 | P(2) |
102 | }; |
103 | const C c(a, a + sizeof(a)/sizeof(a[0])); |
104 | assert(c.bucket_count() >= 7); |
105 | assert(c.size() == 6); |
106 | assert(static_cast<std::size_t>(std::distance(c.begin(), c.end())) == c.size()); |
107 | assert(static_cast<std::size_t>(std::distance(c.cbegin(), c.cend())) == c.size()); |
108 | C::const_iterator i; |
109 | } |
110 | #endif |
111 | #if TEST_STD_VER > 11 |
112 | { // N3644 testing |
113 | typedef std::unordered_multiset<int> C; |
114 | C::iterator ii1{}, ii2{}; |
115 | C::iterator ii4 = ii1; |
116 | C::const_iterator cii{}; |
117 | assert ( ii1 == ii2 ); |
118 | assert ( ii1 == ii4 ); |
119 | |
120 | assert (!(ii1 != ii2 )); |
121 | |
122 | assert ( (ii1 == cii )); |
123 | assert ( (cii == ii1 )); |
124 | assert (!(ii1 != cii )); |
125 | assert (!(cii != ii1 )); |
126 | } |
127 | #endif |
128 | |
129 | return 0; |
130 | } |
131 | |