blob: be21ee210800fd6db90487c8ffdc3ae2d6c26512 [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// <set>
11
12// class set
13
14// template <class... Args>
15// iterator emplace_hint(const_iterator position, Args&&... args);
16
17#include <set>
18#include <cassert>
19
20#include "../../Emplaceable.h"
21#include "../../DefaultOnly.h"
22
23int main()
24{
Howard Hinnant73d21a42010-09-04 23:28:19 +000025#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000026 {
27 typedef std::set<DefaultOnly> M;
28 typedef M::iterator R;
29 M m;
30 assert(DefaultOnly::count == 0);
31 R r = m.emplace_hint(m.cend());
32 assert(r == m.begin());
33 assert(m.size() == 1);
34 assert(*m.begin() == DefaultOnly());
35 assert(DefaultOnly::count == 1);
36
37 r = m.emplace_hint(m.cbegin());
38 assert(r == m.begin());
39 assert(m.size() == 1);
40 assert(*m.begin() == DefaultOnly());
41 assert(DefaultOnly::count == 1);
42 }
43 assert(DefaultOnly::count == 0);
44 {
45 typedef std::set<Emplaceable> M;
46 typedef M::iterator R;
47 M m;
48 R r = m.emplace_hint(m.cend());
49 assert(r == m.begin());
50 assert(m.size() == 1);
51 assert(*m.begin() == Emplaceable());
52 r = m.emplace_hint(m.cend(), 2, 3.5);
53 assert(r == next(m.begin()));
54 assert(m.size() == 2);
55 assert(*r == Emplaceable(2, 3.5));
56 r = m.emplace_hint(m.cbegin(), 2, 3.5);
57 assert(r == next(m.begin()));
58 assert(m.size() == 2);
59 assert(*r == Emplaceable(2, 3.5));
60 }
61 {
62 typedef std::set<int> M;
63 typedef M::iterator R;
64 M m;
65 R r = m.emplace_hint(m.cend(), M::value_type(2));
66 assert(r == m.begin());
67 assert(m.size() == 1);
68 assert(*r == 2);
69 }
Howard Hinnant73d21a42010-09-04 23:28:19 +000070#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000071}