Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / emplace.pass.cpp
blobc247b0b91411046a554bc061c025093489424c7c
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 // <unordered_set>
13 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
14 // class Alloc = allocator<Value>>
15 // class unordered_set
17 // template <class... Args>
18 // pair<iterator, bool> emplace(Args&&... args);
20 #include <unordered_set>
21 #include <cassert>
23 #include "test_macros.h"
24 #include "../../Emplaceable.h"
25 #include "min_allocator.h"
27 int main(int, char**)
30 typedef std::unordered_set<Emplaceable> C;
31 typedef std::pair<C::iterator, bool> R;
32 C c;
33 R r = c.emplace();
34 assert(c.size() == 1);
35 assert(*r.first == Emplaceable());
36 assert(r.second);
38 r = c.emplace(Emplaceable(5, 6));
39 assert(c.size() == 2);
40 assert(*r.first == Emplaceable(5, 6));
41 assert(r.second);
43 r = c.emplace(5, 6);
44 assert(c.size() == 2);
45 assert(*r.first == Emplaceable(5, 6));
46 assert(!r.second);
49 typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
50 std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
51 typedef std::pair<C::iterator, bool> R;
52 C c;
53 R r = c.emplace();
54 assert(c.size() == 1);
55 assert(*r.first == Emplaceable());
56 assert(r.second);
58 r = c.emplace(Emplaceable(5, 6));
59 assert(c.size() == 2);
60 assert(*r.first == Emplaceable(5, 6));
61 assert(r.second);
63 r = c.emplace(5, 6);
64 assert(c.size() == 2);
65 assert(*r.first == Emplaceable(5, 6));
66 assert(!r.second);
69 return 0;