Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / insert_iter_iter.pass.cpp
blob451ee6767100a545df4a0436e0ad5c607e4f4ccb
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 // <unordered_set>
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
15 // template <class InputIterator>
16 // void insert(InputIterator first, InputIterator last);
18 #include <unordered_set>
19 #include <cassert>
21 #include "test_macros.h"
22 #include "test_iterators.h"
23 #include "min_allocator.h"
25 int main(int, char**)
28 typedef std::unordered_set<int> C;
29 typedef int P;
30 P a[] =
32 P(1),
33 P(2),
34 P(3),
35 P(4),
36 P(1),
37 P(2)
39 C c;
40 c.insert(cpp17_input_iterator<P*>(a), cpp17_input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
41 assert(c.size() == 4);
42 assert(c.count(1) == 1);
43 assert(c.count(2) == 1);
44 assert(c.count(3) == 1);
45 assert(c.count(4) == 1);
47 #if TEST_STD_VER >= 11
49 typedef std::unordered_set<int, std::hash<int>,
50 std::equal_to<int>, min_allocator<int>> C;
51 typedef int P;
52 P a[] =
54 P(1),
55 P(2),
56 P(3),
57 P(4),
58 P(1),
59 P(2)
61 C c;
62 c.insert(cpp17_input_iterator<P*>(a), cpp17_input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
63 assert(c.size() == 4);
64 assert(c.count(1) == 1);
65 assert(c.count(2) == 1);
66 assert(c.count(3) == 1);
67 assert(c.count(4) == 1);
69 #endif
71 return 0;