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, const value_type& x);
16
17 #if _LIBCPP_DEBUG >= 1
18 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
19 #endif
20
21 #include <unordered_set>
22 #include <cassert>
23
24 #include "test_macros.h"
25 #include "min_allocator.h"
26
27 template<class Container>
do_insert_hint_const_lvalue_test()28 void do_insert_hint_const_lvalue_test()
29 {
30 typedef Container C;
31 typedef typename C::iterator R;
32 typedef typename C::value_type VT;
33 C c;
34 typename C::const_iterator e = c.end();
35 const VT v1(3.5);
36 R r = c.insert(e, v1);
37 assert(c.size() == 1);
38 assert(*r == 3.5);
39
40 r = c.insert(c.end(), v1);
41 assert(c.size() == 2);
42 assert(*r == 3.5);
43
44 const VT v2(4.5);
45 r = c.insert(c.end(), v2);
46 assert(c.size() == 3);
47 assert(*r == 4.5);
48
49 const VT v3(5.5);
50 r = c.insert(c.end(), v3);
51 assert(c.size() == 4);
52 assert(*r == 5.5);
53 }
54
main(int,char **)55 int main(int, char**)
56 {
57 do_insert_hint_const_lvalue_test<std::unordered_multiset<double> >();
58 #if TEST_STD_VER >= 11
59 {
60 typedef std::unordered_multiset<double, std::hash<double>,
61 std::equal_to<double>, min_allocator<double>> C;
62 do_insert_hint_const_lvalue_test<C>();
63 }
64 #endif
65 #if _LIBCPP_DEBUG >= 1
66 {
67 typedef std::unordered_multiset<double> C;
68 typedef C::iterator R;
69 typedef C::value_type P;
70 C c;
71 C c2;
72 C::const_iterator e = c2.end();
73 P v(3.5);
74 R r = c.insert(e, v);
75 assert(false);
76 }
77 #endif
78
79 return 0;
80 }
81