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_set
15
16 // template <class... Args>
17 // iterator emplace_hint(const_iterator p, Args&&... args);
18
19 #if _LIBCPP_DEBUG >= 1
20 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
21 #endif
22
23 #include <unordered_set>
24 #include <cassert>
25
26 #include "../../Emplaceable.h"
27 #include "min_allocator.h"
28
main()29 int main()
30 {
31 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
32 {
33 typedef std::unordered_set<Emplaceable> C;
34 typedef C::iterator R;
35 C c;
36 C::const_iterator e = c.end();
37 R r = c.emplace_hint(e);
38 assert(c.size() == 1);
39 assert(*r == Emplaceable());
40
41 r = c.emplace_hint(e, Emplaceable(5, 6));
42 assert(c.size() == 2);
43 assert(*r == Emplaceable(5, 6));
44
45 r = c.emplace_hint(r, 5, 6);
46 assert(c.size() == 2);
47 assert(*r == Emplaceable(5, 6));
48 }
49 #if TEST_STD_VER >= 11
50 {
51 typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
52 std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
53 typedef C::iterator R;
54 C c;
55 C::const_iterator e = c.end();
56 R r = c.emplace_hint(e);
57 assert(c.size() == 1);
58 assert(*r == Emplaceable());
59
60 r = c.emplace_hint(e, Emplaceable(5, 6));
61 assert(c.size() == 2);
62 assert(*r == Emplaceable(5, 6));
63
64 r = c.emplace_hint(r, 5, 6);
65 assert(c.size() == 2);
66 assert(*r == Emplaceable(5, 6));
67 }
68 #endif
69 #if _LIBCPP_DEBUG >= 1
70 {
71 typedef std::unordered_set<Emplaceable> C;
72 typedef C::iterator R;
73 C c1;
74 C c2;
75 R r = c1.emplace_hint(c2.begin(), 5, 6);
76 assert(false);
77 }
78 #endif
79 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
80 }
81