[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.multimap / erase_if.pass.cpp
blob23d18872d14287ba04eeaedc7e6743b2c9fe08f4
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 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
10 // <unordered_map>
12 // template <class Key, class T, class Hash, class Pred, class Allocator, class Predicate>
13 // void erase_if(unordered_multimap<Key, T, Hash, Pred, Allocator>& c, Predicate pred);
15 #include <unordered_map>
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
21 using Init = std::initializer_list<int>;
22 template <typename M>
23 M make (Init vals)
25 M ret;
26 for (int v : vals)
27 ret.emplace(static_cast<typename M::key_type>(v), static_cast<typename M::mapped_type>(v + 10));
28 return ret;
31 template <typename M, typename Pred>
32 void
33 test0(Init vals, Pred p, Init expected)
35 M s = make<M> (vals);
36 ASSERT_SAME_TYPE(void, decltype(std::erase_if(s, p)));
37 std::erase_if(s, p);
38 M e = make<M>(expected);
39 assert((std::is_permutation(s.begin(), s.end(), e.begin(), e.end())));
42 template <typename S>
43 void test()
45 auto is1 = [](auto v) { return v.first == 1;};
46 auto is2 = [](auto v) { return v.first == 2;};
47 auto is3 = [](auto v) { return v.first == 3;};
48 auto is4 = [](auto v) { return v.first == 4;};
49 auto True = [](auto) { return true; };
50 auto False = [](auto) { return false; };
52 test0<S>({}, is1, {});
54 test0<S>({1}, is1, {});
55 test0<S>({1}, is2, {1});
57 test0<S>({1,2}, is1, {2});
58 test0<S>({1,2}, is2, {1});
59 test0<S>({1,2}, is3, {1,2});
60 test0<S>({1,1}, is1, {});
61 test0<S>({1,1}, is3, {1,1});
63 test0<S>({1,2,3}, is1, {2,3});
64 test0<S>({1,2,3}, is2, {1,3});
65 test0<S>({1,2,3}, is3, {1,2});
66 test0<S>({1,2,3}, is4, {1,2,3});
68 test0<S>({1,1,1}, is1, {});
69 test0<S>({1,1,1}, is2, {1,1,1});
70 test0<S>({1,1,2}, is1, {2});
71 test0<S>({1,1,2}, is2, {1,1});
72 test0<S>({1,1,2}, is3, {1,1,2});
73 test0<S>({1,2,2}, is1, {2,2});
74 test0<S>({1,2,2}, is2, {1});
75 test0<S>({1,2,2}, is3, {1,2,2});
77 test0<S>({1,2,3}, True, {});
78 test0<S>({1,2,3}, False, {1,2,3});
81 int main(int, char**)
83 test<std::unordered_multimap<int, int>>();
84 test<std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>>> ();
85 test<std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int, int>>>> ();
87 test<std::unordered_multimap<long, short>>();
88 test<std::unordered_multimap<short, double>>();
90 return 0;