1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <unordered_set> 11 12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 13 // class Alloc = allocator<Value>> 14 // class unordered_multiset 15 16 // float load_factor() const 17 18 #include <unordered_set> 19 #include <cassert> 20 #include <cfloat> 21 #include <cmath> 22 23 #include "min_allocator.h" 24 25 int main() 26 { 27 { 28 typedef std::unordered_multiset<int> C; 29 typedef int P; 30 P a[] = 31 { 32 P(10), 33 P(20), 34 P(30), 35 P(40), 36 P(50), 37 P(60), 38 P(70), 39 P(80) 40 }; 41 const C c(std::begin(a), std::end(a)); 42 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); 43 } 44 { 45 typedef std::unordered_multiset<int> C; 46 const C c; 47 assert(c.load_factor() == 0); 48 } 49 #if TEST_STD_VER >= 11 50 { 51 typedef std::unordered_multiset<int, std::hash<int>, 52 std::equal_to<int>, min_allocator<int>> C; 53 typedef int P; 54 P a[] = 55 { 56 P(10), 57 P(20), 58 P(30), 59 P(40), 60 P(50), 61 P(60), 62 P(70), 63 P(80) 64 }; 65 const C c(std::begin(a), std::end(a)); 66 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); 67 } 68 { 69 typedef std::unordered_multiset<int, std::hash<int>, 70 std::equal_to<int>, min_allocator<int>> C; 71 const C c; 72 assert(c.load_factor() == 0); 73 } 74 #endif 75 } 76