blob: 7f3d29763edb456befe2d4ab57e2e669edee19b6 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. 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(value_type&& x);
17
18#include <unordered_set>
19#include <cassert>
20
21#include "../../MoveOnly.h"
22
23int main()
24{
25 {
26 typedef std::unordered_set<double> C;
27 typedef std::pair<C::iterator, bool> R;
28 typedef double 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 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000050#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000051 {
52 typedef std::unordered_set<MoveOnly> C;
53 typedef std::pair<C::iterator, bool> R;
54 typedef MoveOnly P;
55 C c;
56 R r = c.insert(P(3));
57 assert(c.size() == 1);
58 assert(*r.first == 3);
59 assert(r.second);
60
61 r = c.insert(P(3));
62 assert(c.size() == 1);
63 assert(*r.first == 3);
64 assert(!r.second);
65
66 r = c.insert(P(4));
67 assert(c.size() == 2);
68 assert(*r.first == 4);
69 assert(r.second);
70
71 r = c.insert(P(5));
72 assert(c.size() == 3);
73 assert(*r.first == 5);
74 assert(r.second);
75 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000076#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000077}