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 // UNSUPPORTED: c++98, c++03
11
12 // <unordered_set>
13
14 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
15 // class Alloc = allocator<Value>>
16 // class unordered_set
17
18 // template <class... Args>
19 // pair<iterator, bool> emplace(Args&&... args);
20
21 #include <unordered_set>
22 #include <cassert>
23
24 #include "../../Emplaceable.h"
25 #include "min_allocator.h"
26
main()27 int main()
28 {
29 {
30 typedef std::unordered_set<Emplaceable> C;
31 typedef std::pair<C::iterator, bool> R;
32 C c;
33 R r = c.emplace();
34 assert(c.size() == 1);
35 assert(*r.first == Emplaceable());
36 assert(r.second);
37
38 r = c.emplace(Emplaceable(5, 6));
39 assert(c.size() == 2);
40 assert(*r.first == Emplaceable(5, 6));
41 assert(r.second);
42
43 r = c.emplace(5, 6);
44 assert(c.size() == 2);
45 assert(*r.first == Emplaceable(5, 6));
46 assert(!r.second);
47 }
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 }
69