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 // iterator insert(const_iterator p, 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 C::iterator R
;
31 typename
C::const_iterator e
= c
.end();
32 R r
= c
.insert(e
, P(3.5));
33 assert(c
.size() == 1);
36 r
= c
.insert(r
, P(3.5));
37 assert(c
.size() == 1);
40 r
= c
.insert(c
.end(), P(4.5));
41 assert(c
.size() == 2);
44 r
= c
.insert(c
.end(), P(5.5));
45 assert(c
.size() == 3);
48 #if TEST_STD_VER >= 11
50 typedef std::unordered_set
<MoveOnly
> C
;
51 typedef C::iterator R
;
54 typename
C::const_iterator e
= c
.end();
55 R r
= c
.insert(e
, P(3));
56 assert(c
.size() == 1);
59 r
= c
.insert(r
, P(3));
60 assert(c
.size() == 1);
63 r
= c
.insert(c
.end(), P(4));
64 assert(c
.size() == 2);
67 r
= c
.insert(c
.end(), P(5));
68 assert(c
.size() == 3);
72 typedef std::unordered_set
<double, std::hash
<double>,
73 std::equal_to
<double>, min_allocator
<double>> C
;
74 typedef C::iterator R
;
77 typename
C::const_iterator e
= c
.end();
78 R r
= c
.insert(e
, P(3.5));
79 assert(c
.size() == 1);
82 r
= c
.insert(r
, P(3.5));
83 assert(c
.size() == 1);
86 r
= c
.insert(c
.end(), P(4.5));
87 assert(c
.size() == 2);
90 r
= c
.insert(c
.end(), P(5.5));
91 assert(c
.size() == 3);
95 typedef std::unordered_set
<MoveOnly
, std::hash
<MoveOnly
>,
96 std::equal_to
<MoveOnly
>, min_allocator
<MoveOnly
>> C
;
97 typedef C::iterator R
;
100 typename
C::const_iterator e
= c
.end();
101 R r
= c
.insert(e
, P(3));
102 assert(c
.size() == 1);
105 r
= c
.insert(r
, P(3));
106 assert(c
.size() == 1);
109 r
= c
.insert(c
.end(), P(4));
110 assert(c
.size() == 2);
113 r
= c
.insert(c
.end(), P(5));
114 assert(c
.size() == 3);
117 #endif // TEST_STD_VER >= 11