1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
14 // class unordered_multimap
16 // node_type extract(key_type const&);
18 #include <unordered_map>
19 #include "min_allocator.h"
22 template <class Container, class KeyTypeIter>
23 void test(Container& c, KeyTypeIter first, KeyTypeIter last)
26 assert((size_t)std::distance(first, last) == sz);
28 for (KeyTypeIter copy = first; copy != last; ++copy)
30 typename Container::node_type t = c.extract(*copy);
33 assert(t.key() == *copy);
34 t.key() = *first; // We should be able to mutate key.
35 assert(t.key() == *first);
36 assert(t.get_allocator() == c.get_allocator());
37 assert(sz == c.size());
40 assert(c.size() == 0);
42 for (KeyTypeIter copy = first; copy != last; ++copy)
44 typename Container::node_type t = c.extract(*copy);
52 std::unordered_multimap<int, int> m =
53 {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
54 int keys[] = {1, 2, 3, 4, 5, 6};
55 test(m, std::begin(keys), std::end(keys));
59 std::unordered_multimap<Counter<int>, Counter<int>> m =
60 {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
62 Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
63 assert(Counter_base::gConstructed == 12+6);
64 test(m, std::begin(keys), std::end(keys));
66 assert(Counter_base::gConstructed == 0);
71 std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
72 min_allocator<std::pair<const int, int>>>;
73 min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
74 int keys[] = {1, 2, 3, 4, 5, 6};
75 test(m, std::begin(keys), std::end(keys));