| 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 | // float load_factor() const |
| 16 | |
| 17 | #include <unordered_set> |
| 18 | #include <cassert> |
| 19 | #include <cfloat> |
| 20 | #include <cmath> |
| 21 | |
| 22 | #include "test_macros.h" |
| 23 | #include "min_allocator.h" |
| 24 | |
| 25 | int main(int, char**) { |
| 26 | { |
| 27 | typedef std::unordered_multiset<int> C; |
| 28 | typedef int P; |
| 29 | P a[] = {P(10), P(20), P(30), P(40), P(50), P(60), P(70), P(80)}; |
| 30 | const C c(std::begin(arr&: a), std::end(arr&: a)); |
| 31 | assert(std::fabs(c.load_factor() - (float)c.size() / c.bucket_count()) < FLT_EPSILON); |
| 32 | } |
| 33 | { |
| 34 | typedef std::unordered_multiset<int> C; |
| 35 | const C c; |
| 36 | assert(c.load_factor() == 0); |
| 37 | } |
| 38 | #if TEST_STD_VER >= 11 |
| 39 | { |
| 40 | typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; |
| 41 | typedef int P; |
| 42 | P a[] = {P(10), P(20), P(30), P(40), P(50), P(60), P(70), P(80)}; |
| 43 | const C c(std::begin(a), std::end(a)); |
| 44 | assert(std::fabs(c.load_factor() - (float)c.size() / c.bucket_count()) < FLT_EPSILON); |
| 45 | } |
| 46 | { |
| 47 | typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; |
| 48 | const C c; |
| 49 | assert(c.load_factor() == 0); |
| 50 | } |
| 51 | #endif |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |