Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / set / emplace_hint.pass.cpp
bloba7d6857a820b89af6d0e765e518cd45c60a3df20
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <set>
13 // class set
15 // template <class... Args>
16 // iterator emplace_hint(const_iterator position, Args&&... args);
18 #include <set>
19 #include <cassert>
21 #include "test_macros.h"
22 #include "../../Emplaceable.h"
23 #include "DefaultOnly.h"
24 #include "min_allocator.h"
26 int main(int, char**)
29 typedef std::set<DefaultOnly> M;
30 typedef M::iterator R;
31 M m;
32 assert(DefaultOnly::count == 0);
33 R r = m.emplace_hint(m.cend());
34 assert(r == m.begin());
35 assert(m.size() == 1);
36 assert(*m.begin() == DefaultOnly());
37 assert(DefaultOnly::count == 1);
39 r = m.emplace_hint(m.cbegin());
40 assert(r == m.begin());
41 assert(m.size() == 1);
42 assert(*m.begin() == DefaultOnly());
43 assert(DefaultOnly::count == 1);
45 assert(DefaultOnly::count == 0);
47 typedef std::set<Emplaceable> M;
48 typedef M::iterator R;
49 M m;
50 R r = m.emplace_hint(m.cend());
51 assert(r == m.begin());
52 assert(m.size() == 1);
53 assert(*m.begin() == Emplaceable());
54 r = m.emplace_hint(m.cend(), 2, 3.5);
55 assert(r == std::next(m.begin()));
56 assert(m.size() == 2);
57 assert(*r == Emplaceable(2, 3.5));
58 r = m.emplace_hint(m.cbegin(), 2, 3.5);
59 assert(r == std::next(m.begin()));
60 assert(m.size() == 2);
61 assert(*r == Emplaceable(2, 3.5));
64 typedef std::set<int> M;
65 typedef M::iterator R;
66 M m;
67 R r = m.emplace_hint(m.cend(), M::value_type(2));
68 assert(r == m.begin());
69 assert(m.size() == 1);
70 assert(*r == 2);
73 typedef std::set<int, std::less<int>, min_allocator<int>> M;
74 typedef M::iterator R;
75 M m;
76 R r = m.emplace_hint(m.cend(), M::value_type(2));
77 assert(r == m.begin());
78 assert(m.size() == 1);
79 assert(*r == 2);
82 return 0;