1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++98, c++03, c++11, c++14
10 
11 // <unordered_set>
12 
13 // class unordered_multiset
14 
15 // iterator insert(const_iterator hint, node_type&&);
16 
17 #include <unordered_set>
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 
21 template <class Container>
22 typename Container::node_type
node_factory(typename Container::key_type const & key)23 node_factory(typename Container::key_type const& key)
24 {
25     static Container c;
26     auto it = c.insert(key);
27     return c.extract(it);
28 }
29 
30 template <class Container>
test(Container & c)31 void test(Container& c)
32 {
33     auto* nf = &node_factory<Container>;
34 
35     for (int i = 0; i != 10; ++i)
36     {
37         typename Container::node_type node = nf(i);
38         assert(!node.empty());
39         size_t prev = c.size();
40         auto it = c.insert(c.end(), std::move(node));
41         assert(prev + 1 == c.size());
42         assert(*it == i);
43     }
44 
45     assert(c.size() == 10);
46 
47     for (int i = 0; i != 10; ++i)
48     {
49         assert(c.count(i) == 1);
50     }
51 }
52 
main(int,char **)53 int main(int, char**)
54 {
55     std::unordered_multiset<int> m;
56     test(m);
57     std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> m2;
58     test(m2);
59 
60   return 0;
61 }
62