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_multimap
15
16 // template <class... Args>
17 // iterator emplace_hint(const_iterator p, Args&&... args);
18
19 #if _LIBCPP_DEBUG >= 1
20 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
21 #endif
22
23 #include <unordered_map>
24 #include <cassert>
25
26 #include "../../../Emplaceable.h"
27 #include "min_allocator.h"
28
main()29 int main()
30 {
31 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
32 {
33 typedef std::unordered_multimap<int, Emplaceable> C;
34 typedef C::iterator R;
35 C c;
36 C::const_iterator e = c.end();
37 R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
38 std::forward_as_tuple());
39 assert(c.size() == 1);
40 assert(r->first == 3);
41 assert(r->second == Emplaceable());
42
43 r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
44 assert(c.size() == 2);
45 assert(r->first == 3);
46 assert(r->second == Emplaceable(5, 6));
47 assert(r == next(c.begin()));
48
49 r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
50 std::forward_as_tuple(6, 7));
51 assert(c.size() == 3);
52 assert(r->first == 3);
53 assert(r->second == Emplaceable(6, 7));
54 assert(r == next(c.begin()));
55 r = c.begin();
56 assert(r->first == 3);
57 assert(r->second == Emplaceable());
58 r = next(r, 2);
59 assert(r->first == 3);
60 assert(r->second == Emplaceable(5, 6));
61 }
62 #if __cplusplus >= 201103L
63 {
64 typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
65 min_allocator<std::pair<const int, Emplaceable>>> C;
66 typedef C::iterator R;
67 C c;
68 C::const_iterator e = c.end();
69 R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
70 std::forward_as_tuple());
71 assert(c.size() == 1);
72 assert(r->first == 3);
73 assert(r->second == Emplaceable());
74
75 r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
76 assert(c.size() == 2);
77 assert(r->first == 3);
78 assert(r->second == Emplaceable(5, 6));
79 assert(r == next(c.begin()));
80
81 r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
82 std::forward_as_tuple(6, 7));
83 assert(c.size() == 3);
84 assert(r->first == 3);
85 assert(r->second == Emplaceable(6, 7));
86 assert(r == next(c.begin()));
87 r = c.begin();
88 assert(r->first == 3);
89 assert(r->second == Emplaceable());
90 r = next(r, 2);
91 assert(r->first == 3);
92 assert(r->second == Emplaceable(5, 6));
93 }
94 #endif
95 #if _LIBCPP_DEBUG >= 1
96 {
97 typedef std::unordered_multimap<int, Emplaceable> C;
98 typedef C::iterator R;
99 typedef C::value_type P;
100 C c;
101 C c2;
102 R r = c.emplace_hint(c2.end(), std::piecewise_construct,
103 std::forward_as_tuple(3),
104 std::forward_as_tuple());
105 assert(false);
106 }
107 #endif
108 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
109 }
110