1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
15 // pair<iterator, bool> insert(value_type&& x);
17 #include <unordered_set>
20 #include "test_macros.h"
22 #include "min_allocator.h"
27 typedef std::unordered_set
<double> C
;
28 typedef std::pair
<C::iterator
, bool> R
;
31 R r
= c
.insert(P(3.5));
32 assert(c
.size() == 1);
33 assert(*r
.first
== 3.5);
37 assert(c
.size() == 1);
38 assert(*r
.first
== 3.5);
42 assert(c
.size() == 2);
43 assert(*r
.first
== 4.5);
47 assert(c
.size() == 3);
48 assert(*r
.first
== 5.5);
51 #if TEST_STD_VER >= 11
53 typedef std::unordered_set
<MoveOnly
> C
;
54 typedef std::pair
<C::iterator
, bool> R
;
58 assert(c
.size() == 1);
59 assert(*r
.first
== 3);
63 assert(c
.size() == 1);
64 assert(*r
.first
== 3);
68 assert(c
.size() == 2);
69 assert(*r
.first
== 4);
73 assert(c
.size() == 3);
74 assert(*r
.first
== 5);
78 typedef std::unordered_set
<double, std::hash
<double>,
79 std::equal_to
<double>, min_allocator
<double>> C
;
80 typedef std::pair
<C::iterator
, bool> R
;
83 R r
= c
.insert(P(3.5));
84 assert(c
.size() == 1);
85 assert(*r
.first
== 3.5);
89 assert(c
.size() == 1);
90 assert(*r
.first
== 3.5);
94 assert(c
.size() == 2);
95 assert(*r
.first
== 4.5);
99 assert(c
.size() == 3);
100 assert(*r
.first
== 5.5);
104 typedef std::unordered_set
<MoveOnly
, std::hash
<MoveOnly
>,
105 std::equal_to
<MoveOnly
>, min_allocator
<MoveOnly
>> C
;
106 typedef std::pair
<C::iterator
, bool> R
;
109 R r
= c
.insert(P(3));
110 assert(c
.size() == 1);
111 assert(*r
.first
== 3);
115 assert(c
.size() == 1);
116 assert(*r
.first
== 3);
120 assert(c
.size() == 2);
121 assert(*r
.first
== 4);
125 assert(c
.size() == 3);
126 assert(*r
.first
== 5);
129 #endif // TEST_STD_VER >= 11