• 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 // <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 // pair<iterator, bool> insert(const value_type& x);
17 
18 #include <unordered_set>
19 #include <cassert>
20 
21 #include "min_allocator.h"
22 
main()23 int main()
24 {
25     {
26         typedef std::unordered_set<double> C;
27         typedef std::pair<C::iterator, bool> R;
28         typedef C::value_type P;
29         C c;
30         R r = c.insert(P(3.5));
31         assert(c.size() == 1);
32         assert(*r.first == 3.5);
33         assert(r.second);
34 
35         r = c.insert(P(3.5));
36         assert(c.size() == 1);
37         assert(*r.first == 3.5);
38         assert(!r.second);
39 
40         r = c.insert(P(4.5));
41         assert(c.size() == 2);
42         assert(*r.first == 4.5);
43         assert(r.second);
44 
45         r = c.insert(P(5.5));
46         assert(c.size() == 3);
47         assert(*r.first == 5.5);
48         assert(r.second);
49     }
50 #if __cplusplus >= 201103L
51     {
52         typedef std::unordered_set<double, std::hash<double>,
53                                 std::equal_to<double>, min_allocator<double>> C;
54         typedef std::pair<C::iterator, bool> R;
55         typedef C::value_type P;
56         C c;
57         R r = c.insert(P(3.5));
58         assert(c.size() == 1);
59         assert(*r.first == 3.5);
60         assert(r.second);
61 
62         r = c.insert(P(3.5));
63         assert(c.size() == 1);
64         assert(*r.first == 3.5);
65         assert(!r.second);
66 
67         r = c.insert(P(4.5));
68         assert(c.size() == 2);
69         assert(*r.first == 4.5);
70         assert(r.second);
71 
72         r = c.insert(P(5.5));
73         assert(c.size() == 3);
74         assert(*r.first == 5.5);
75         assert(r.second);
76     }
77 #endif
78 }
79