size_hash_equal.pass.cpp revision 7a6b7cedcb3359ad7d77e355b02ab982d9d2b25b
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_map> 11 12// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 13// class Alloc = allocator<pair<const Key, T>>> 14// class unordered_map 15 16// unordered_map(size_type n, const hasher& hf, const key_equal& eql); 17 18#include <unordered_map> 19#include <cassert> 20 21#include "../../../NotConstructible.h" 22#include "../../../test_compare.h" 23#include "../../../test_hash.h" 24#include "../../../test_allocator.h" 25#include "../../../min_allocator.h" 26 27int main() 28{ 29 { 30 typedef std::unordered_map<NotConstructible, NotConstructible, 31 test_hash<std::hash<NotConstructible> >, 32 test_compare<std::equal_to<NotConstructible> >, 33 test_allocator<std::pair<const NotConstructible, 34 NotConstructible> > 35 > C; 36 C c(7, 37 test_hash<std::hash<NotConstructible> >(8), 38 test_compare<std::equal_to<NotConstructible> >(9) 39 ); 40 assert(c.bucket_count() == 7); 41 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8)); 42 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9)); 43 assert(c.get_allocator() == 44 (test_allocator<std::pair<const NotConstructible, NotConstructible> >())); 45 assert(c.size() == 0); 46 assert(c.empty()); 47 assert(std::distance(c.begin(), c.end()) == 0); 48 assert(c.load_factor() == 0); 49 assert(c.max_load_factor() == 1); 50 } 51#if __cplusplus >= 201103L 52 { 53 typedef std::unordered_map<NotConstructible, NotConstructible, 54 test_hash<std::hash<NotConstructible> >, 55 test_compare<std::equal_to<NotConstructible> >, 56 min_allocator<std::pair<const NotConstructible, 57 NotConstructible> > 58 > C; 59 C c(7, 60 test_hash<std::hash<NotConstructible> >(8), 61 test_compare<std::equal_to<NotConstructible> >(9) 62 ); 63 assert(c.bucket_count() == 7); 64 assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8)); 65 assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9)); 66 assert(c.get_allocator() == 67 (min_allocator<std::pair<const NotConstructible, NotConstructible> >())); 68 assert(c.size() == 0); 69 assert(c.empty()); 70 assert(std::distance(c.begin(), c.end()) == 0); 71 assert(c.load_factor() == 0); 72 assert(c.max_load_factor() == 1); 73 } 74#endif 75} 76