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_set |
14 | |
15 | // size_type bucket_count() const; |
16 | |
17 | #include <unordered_set> |
18 | #include <cassert> |
19 | |
20 | #include "test_macros.h" |
21 | #include "min_allocator.h" |
22 | |
23 | int main(int, char**) |
24 | { |
25 | { |
26 | typedef std::unordered_set<int> C; |
27 | const C c; |
28 | LIBCPP_ASSERT(c.bucket_count() == 0); |
29 | } |
30 | { |
31 | typedef std::unordered_set<int> C; |
32 | typedef int P; |
33 | P a[] = |
34 | { |
35 | P(10), |
36 | P(20), |
37 | P(30), |
38 | P(40), |
39 | P(50), |
40 | P(60), |
41 | P(70), |
42 | P(80) |
43 | }; |
44 | const C c(std::begin(arr&: a), std::end(arr&: a)); |
45 | assert(c.bucket_count() >= 8); |
46 | } |
47 | #if TEST_STD_VER >= 11 |
48 | { |
49 | typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; |
50 | const C c; |
51 | LIBCPP_ASSERT(c.bucket_count() == 0); |
52 | } |
53 | { |
54 | typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; |
55 | typedef int P; |
56 | P a[] = |
57 | { |
58 | P(10), |
59 | P(20), |
60 | P(30), |
61 | P(40), |
62 | P(50), |
63 | P(60), |
64 | P(70), |
65 | P(80) |
66 | }; |
67 | const C c(std::begin(a), std::end(a)); |
68 | assert(c.bucket_count() >= 8); |
69 | } |
70 | #endif |
71 | |
72 | return 0; |
73 | } |
74 | |