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, class Pred, class Alloc>
13 // bool
14 // operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
15 // const unordered_map<Key, T, Hash, Pred, Alloc>& y);
16 //
17 // template <class Key, class T, class Hash, class Pred, class Alloc>
18 // bool
19 // operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
20 // const unordered_map<Key, T, Hash, Pred, Alloc>& y);
21
22 #include <unordered_map>
23 #include <string>
24 #include <cassert>
25
main()26 int 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(10, "ten"),
34 P(20, "twenty"),
35 P(30, "thirty"),
36 P(40, "fourty"),
37 P(50, "fifty"),
38 P(60, "sixty"),
39 P(70, "seventy"),
40 P(80, "eighty"),
41 };
42 const C c1(std::begin(a), std::end(a));
43 const C c2;
44 assert(!(c1 == c2));
45 assert( (c1 != c2));
46 }
47 {
48 typedef std::unordered_map<int, std::string> C;
49 typedef std::pair<int, std::string> P;
50 P a[] =
51 {
52 P(10, "ten"),
53 P(20, "twenty"),
54 P(30, "thirty"),
55 P(40, "fourty"),
56 P(50, "fifty"),
57 P(60, "sixty"),
58 P(70, "seventy"),
59 P(80, "eighty"),
60 };
61 const C c1(std::begin(a), std::end(a));
62 const C c2 = c1;
63 assert( (c1 == c2));
64 assert(!(c1 != c2));
65 }
66 {
67 typedef std::unordered_map<int, std::string> C;
68 typedef std::pair<int, std::string> P;
69 P a[] =
70 {
71 P(10, "ten"),
72 P(20, "twenty"),
73 P(30, "thirty"),
74 P(40, "fourty"),
75 P(50, "fifty"),
76 P(60, "sixty"),
77 P(70, "seventy"),
78 P(80, "eighty"),
79 };
80 C c1(std::begin(a), std::end(a));
81 C c2 = c1;
82 c2.rehash(30);
83 assert( (c1 == c2));
84 assert(!(c1 != c2));
85 c2.insert(P(90, "ninety"));
86 assert(!(c1 == c2));
87 assert( (c1 != c2));
88 c1.insert(P(90, "ninety"));
89 assert( (c1 == c2));
90 assert(!(c1 != c2));
91 }
92 }
93