• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //     iterator emplace_hint(const_iterator p, Args&&... args);
20 
21 
22 #include <unordered_set>
23 #include <cassert>
24 
25 #include "../../Emplaceable.h"
26 #include "min_allocator.h"
27 
main()28 int main()
29 {
30     {
31         typedef std::unordered_set<Emplaceable> C;
32         typedef C::iterator R;
33         C c;
34         C::const_iterator e = c.end();
35         R r = c.emplace_hint(e);
36         assert(c.size() == 1);
37         assert(*r == Emplaceable());
38 
39         r = c.emplace_hint(e, Emplaceable(5, 6));
40         assert(c.size() == 2);
41         assert(*r == Emplaceable(5, 6));
42 
43         r = c.emplace_hint(r, 5, 6);
44         assert(c.size() == 2);
45         assert(*r == Emplaceable(5, 6));
46     }
47     {
48         typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
49                       std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
50         typedef C::iterator R;
51         C c;
52         C::const_iterator e = c.end();
53         R r = c.emplace_hint(e);
54         assert(c.size() == 1);
55         assert(*r == Emplaceable());
56 
57         r = c.emplace_hint(e, Emplaceable(5, 6));
58         assert(c.size() == 2);
59         assert(*r == Emplaceable(5, 6));
60 
61         r = c.emplace_hint(r, 5, 6);
62         assert(c.size() == 2);
63         assert(*r == Emplaceable(5, 6));
64     }
65 }
66