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 // void insert(initializer_list<value_type> il);
17 
18 #include <unordered_map>
19 #include <string>
20 #include <cassert>
21 
22 #include "test_iterators.h"
23 #include "../../../min_allocator.h"
24 
25 int main()
26 {
27 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
28     {
29         typedef std::unordered_map<int, std::string> C;
30         typedef std::pair<int, std::string> P;
31         C c;
32         c.insert(
33                     {
34                         P(1, "one"),
35                         P(2, "two"),
36                         P(3, "three"),
37                         P(4, "four"),
38                         P(1, "four"),
39                         P(2, "four"),
40                     }
41                 );
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         C c;
54         c.insert(
55                     {
56                         P(1, "one"),
57                         P(2, "two"),
58                         P(3, "three"),
59                         P(4, "four"),
60                         P(1, "four"),
61                         P(2, "four"),
62                     }
63                 );
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 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
72 }
73