1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <unordered_set>
11
12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
13 // class Alloc = allocator<Value>>
14 // class unordered_multiset
15
16 // iterator insert(const_iterator p, const value_type& x);
17
18 #if _LIBCPP_DEBUG >= 1
19 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
20 #endif
21
22 #include <unordered_set>
23 #include <cassert>
24
25 #include "min_allocator.h"
26
main()27 int main()
28 {
29 {
30 typedef std::unordered_multiset<double> C;
31 typedef C::iterator R;
32 typedef C::value_type P;
33 C c;
34 C::const_iterator e = c.end();
35 R r = c.insert(e, P(3.5));
36 assert(c.size() == 1);
37 assert(*r == 3.5);
38
39 r = c.insert(c.end(), P(3.5));
40 assert(c.size() == 2);
41 assert(*r == 3.5);
42
43 r = c.insert(c.end(), P(4.5));
44 assert(c.size() == 3);
45 assert(*r == 4.5);
46
47 r = c.insert(c.end(), P(5.5));
48 assert(c.size() == 4);
49 assert(*r == 5.5);
50 }
51 #if __cplusplus >= 201103L
52 {
53 typedef std::unordered_multiset<double, std::hash<double>,
54 std::equal_to<double>, min_allocator<double>> C;
55 typedef C::iterator R;
56 typedef C::value_type P;
57 C c;
58 C::const_iterator e = c.end();
59 R r = c.insert(e, P(3.5));
60 assert(c.size() == 1);
61 assert(*r == 3.5);
62
63 r = c.insert(c.end(), P(3.5));
64 assert(c.size() == 2);
65 assert(*r == 3.5);
66
67 r = c.insert(c.end(), P(4.5));
68 assert(c.size() == 3);
69 assert(*r == 4.5);
70
71 r = c.insert(c.end(), P(5.5));
72 assert(c.size() == 4);
73 assert(*r == 5.5);
74 }
75 #endif
76 #if _LIBCPP_DEBUG >= 1
77 {
78 typedef std::unordered_multiset<double> C;
79 typedef C::iterator R;
80 typedef C::value_type P;
81 C c;
82 C c2;
83 C::const_iterator e = c2.end();
84 P v(3.5);
85 R r = c.insert(e, v);
86 assert(false);
87 }
88 #endif
89 }
90