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// <unordered_set>
10
11// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12// class Alloc = allocator<Value>>
13// class unordered_multiset
14
15// iterator insert(const_iterator p, value_type&& x);
16
17#include <unordered_set>
18#include <cassert>
19
20#include "test_macros.h"
21#include "MoveOnly.h"
22#include "min_allocator.h"
23
24int main(int, char**) {
25 {
26 typedef std::unordered_multiset<double> C;
27 typedef C::iterator R;
28 typedef double P;
29 C c;
30 C::const_iterator e = c.end();
31 R r = c.insert(hint: e, x: P(3.5));
32 assert(c.size() == 1);
33 assert(*r == 3.5);
34
35 r = c.insert(hint: r, x: P(3.5));
36 assert(c.size() == 2);
37 assert(*r == 3.5);
38
39 r = c.insert(hint: c.end(), x: P(4.5));
40 assert(c.size() == 3);
41 assert(*r == 4.5);
42
43 r = c.insert(hint: c.end(), x: P(5.5));
44 assert(c.size() == 4);
45 assert(*r == 5.5);
46 }
47#if TEST_STD_VER >= 11
48 {
49 typedef std::unordered_multiset<MoveOnly> C;
50 typedef C::iterator R;
51 typedef MoveOnly P;
52 C c;
53 C::const_iterator e = c.end();
54 R r = c.insert(e, P(3));
55 assert(c.size() == 1);
56 assert(*r == 3);
57
58 r = c.insert(r, P(3));
59 assert(c.size() == 2);
60 assert(*r == 3);
61
62 r = c.insert(c.end(), P(4));
63 assert(c.size() == 3);
64 assert(*r == 4);
65
66 r = c.insert(c.end(), P(5));
67 assert(c.size() == 4);
68 assert(*r == 5);
69 }
70 {
71 typedef std::unordered_multiset<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C;
72 typedef C::iterator R;
73 typedef double P;
74 C c;
75 C::const_iterator e = c.end();
76 R r = c.insert(e, P(3.5));
77 assert(c.size() == 1);
78 assert(*r == 3.5);
79
80 r = c.insert(r, P(3.5));
81 assert(c.size() == 2);
82 assert(*r == 3.5);
83
84 r = c.insert(c.end(), P(4.5));
85 assert(c.size() == 3);
86 assert(*r == 4.5);
87
88 r = c.insert(c.end(), P(5.5));
89 assert(c.size() == 4);
90 assert(*r == 5.5);
91 }
92 {
93 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
94 typedef C::iterator R;
95 typedef MoveOnly P;
96 C c;
97 C::const_iterator e = c.end();
98 R r = c.insert(e, P(3));
99 assert(c.size() == 1);
100 assert(*r == 3);
101
102 r = c.insert(r, P(3));
103 assert(c.size() == 2);
104 assert(*r == 3);
105
106 r = c.insert(c.end(), P(4));
107 assert(c.size() == 3);
108 assert(*r == 4);
109
110 r = c.insert(c.end(), P(5));
111 assert(c.size() == 4);
112 assert(*r == 5);
113 }
114#endif // TEST_STD_VER >= 11
115
116 return 0;
117}
118

source code of libcxx/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp