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 // pair<iterator, bool> emplace(Args&&... args);
18
19 #include <unordered_set>
20 #include <cassert>
21
22 #include "../../Emplaceable.h"
23 #include "min_allocator.h"
24
main()25 int main()
26 {
27 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
28 {
29 typedef std::unordered_set<Emplaceable> C;
30 typedef std::pair<C::iterator, bool> R;
31 C c;
32 R r = c.emplace();
33 assert(c.size() == 1);
34 assert(*r.first == Emplaceable());
35 assert(r.second);
36
37 r = c.emplace(Emplaceable(5, 6));
38 assert(c.size() == 2);
39 assert(*r.first == Emplaceable(5, 6));
40 assert(r.second);
41
42 r = c.emplace(5, 6);
43 assert(c.size() == 2);
44 assert(*r.first == Emplaceable(5, 6));
45 assert(!r.second);
46 }
47 #if TEST_STD_VER >= 11
48 {
49 typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
50 std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
51 typedef std::pair<C::iterator, bool> R;
52 C c;
53 R r = c.emplace();
54 assert(c.size() == 1);
55 assert(*r.first == Emplaceable());
56 assert(r.second);
57
58 r = c.emplace(Emplaceable(5, 6));
59 assert(c.size() == 2);
60 assert(*r.first == Emplaceable(5, 6));
61 assert(r.second);
62
63 r = c.emplace(5, 6);
64 assert(c.size() == 2);
65 assert(*r.first == Emplaceable(5, 6));
66 assert(!r.second);
67 }
68 #endif
69 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
70 }
71