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 // void reserve(size_type n);
17 #include <unordered_set>
20 #include "test_macros.h"
21 #include "min_allocator.h"
26 assert(c
.size() == 6);
27 assert(c
.count(1) == 2);
28 assert(c
.count(2) == 2);
29 assert(c
.count(3) == 1);
30 assert(c
.count(4) == 1);
33 void reserve_invariant(std::size_t n
) // LWG #2156
35 for (std::size_t i
= 0; i
< n
; ++i
)
37 std::unordered_multiset
<std::size_t> c
;
39 std::size_t buckets
= c
.bucket_count();
40 for (std::size_t j
= 0; j
< i
; ++j
)
43 assert(buckets
== c
.bucket_count());
51 typedef std::unordered_multiset
<int> C
;
62 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
64 assert(c
.bucket_count() >= 7);
66 LIBCPP_ASSERT(c
.bucket_count() == 7);
70 LIBCPP_ASSERT(c
.bucket_count() == 3);
73 assert(c
.bucket_count() >= 16);
76 #if TEST_STD_VER >= 11
78 typedef std::unordered_multiset
<int, std::hash
<int>,
79 std::equal_to
<int>, min_allocator
<int>> C
;
90 C
c(a
, a
+ sizeof(a
)/sizeof(a
[0]));
92 assert(c
.bucket_count() >= 7);
94 LIBCPP_ASSERT(c
.bucket_count() == 7);
98 LIBCPP_ASSERT(c
.bucket_count() == 3);
101 assert(c
.bucket_count() >= 16);
105 reserve_invariant(20);