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// template <class InputIterator> 17// void insert(InputIterator first, InputIterator last); 18 19#include <unordered_map> 20#include <string> 21#include <cassert> 22 23#include "test_iterators.h" 24#include "min_allocator.h" 25 26int main() 27{ 28 { 29 typedef std::unordered_map<int, std::string> C; 30 typedef std::pair<int, std::string> P; 31 P a[] = 32 { 33 P(1, "one"), 34 P(2, "two"), 35 P(3, "three"), 36 P(4, "four"), 37 P(1, "four"), 38 P(2, "four"), 39 }; 40 C c; 41 c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0]))); 42 assert(c.size() == 4); 43 assert(c.at(1) == "one"); 44 assert(c.at(2) == "two"); 45 assert(c.at(3) == "three"); 46 assert(c.at(4) == "four"); 47 } 48#if __cplusplus >= 201103L 49 { 50 typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, 51 min_allocator<std::pair<const int, std::string>>> C; 52 typedef std::pair<int, std::string> P; 53 P a[] = 54 { 55 P(1, "one"), 56 P(2, "two"), 57 P(3, "three"), 58 P(4, "four"), 59 P(1, "four"), 60 P(2, "four"), 61 }; 62 C c; 63 c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0]))); 64 assert(c.size() == 4); 65 assert(c.at(1) == "one"); 66 assert(c.at(2) == "two"); 67 assert(c.at(3) == "three"); 68 assert(c.at(4) == "four"); 69 } 70#endif 71} 72