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(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 {
27 typedef std::unordered_multiset<double> C;
28 typedef C::iterator R;
29 typedef double P;
30 C c;
31 R r = c.insert(x: P(3.5));
32 assert(c.size() == 1);
33 assert(*r == 3.5);
34
35 r = c.insert(x: P(3.5));
36 assert(c.size() == 2);
37 assert(*r == 3.5);
38
39 r = c.insert(x: P(4.5));
40 assert(c.size() == 3);
41 assert(*r == 4.5);
42
43 r = c.insert(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 R r = c.insert(P(3));
54 assert(c.size() == 1);
55 assert(*r == 3);
56
57 r = c.insert(P(3));
58 assert(c.size() == 2);
59 assert(*r == 3);
60
61 r = c.insert(P(4));
62 assert(c.size() == 3);
63 assert(*r == 4);
64
65 r = c.insert(P(5));
66 assert(c.size() == 4);
67 assert(*r == 5);
68 }
69 {
70 typedef std::unordered_multiset<double, std::hash<double>,
71 std::equal_to<double>, min_allocator<double>> C;
72 typedef C::iterator R;
73 typedef double P;
74 C c;
75 R r = c.insert(P(3.5));
76 assert(c.size() == 1);
77 assert(*r == 3.5);
78
79 r = c.insert(P(3.5));
80 assert(c.size() == 2);
81 assert(*r == 3.5);
82
83 r = c.insert(P(4.5));
84 assert(c.size() == 3);
85 assert(*r == 4.5);
86
87 r = c.insert(P(5.5));
88 assert(c.size() == 4);
89 assert(*r == 5.5);
90 }
91 {
92 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
93 std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
94 typedef C::iterator R;
95 typedef MoveOnly P;
96 C c;
97 R r = c.insert(P(3));
98 assert(c.size() == 1);
99 assert(*r == 3);
100
101 r = c.insert(P(3));
102 assert(c.size() == 2);
103 assert(*r == 3);
104
105 r = c.insert(P(4));
106 assert(c.size() == 3);
107 assert(*r == 4);
108
109 r = c.insert(P(5));
110 assert(c.size() == 4);
111 assert(*r == 5);
112 }
113#endif // TEST_STD_VER >= 11
114
115 return 0;
116}
117

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