emplace_hint.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
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 multiset
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{
25#ifdef _LIBCPP_MOVE
26    {
27        typedef std::multiset<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() == 2);
40        assert(*m.begin() == DefaultOnly());
41        assert(DefaultOnly::count == 2);
42    }
43    assert(DefaultOnly::count == 0);
44    {
45        typedef std::multiset<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() == 3);
59        assert(*r == Emplaceable(2, 3.5));
60    }
61    {
62        typedef std::multiset<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    }
70#endif
71}
72