[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / sequences / vector / vector.erasure / erase.pass.cpp
blob687a467e4f7dc8fe652bc900956281ad0b9897d0
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 // <vector>
12 // template <class T, class Allocator, class U>
13 // void erase(vector<T, Allocator>& c, const U& value);
16 #include <vector>
17 #include <optional>
19 #include "test_macros.h"
20 #include "test_allocator.h"
21 #include "min_allocator.h"
23 template <class S, class U>
24 void
25 test0(S s, U val, S expected)
27 ASSERT_SAME_TYPE(void, decltype(std::erase(s, val)));
28 std::erase(s, val);
29 assert(s == expected);
32 template <class S>
33 void test()
36 test0(S(), 1, S());
38 test0(S({1}), 1, S());
39 test0(S({1}), 2, S({1}));
41 test0(S({1,2}), 1, S({2}));
42 test0(S({1,2}), 2, S({1}));
43 test0(S({1,2}), 3, S({1,2}));
44 test0(S({1,1}), 1, S());
45 test0(S({1,1}), 3, S({1,1}));
47 test0(S({1,2,3}), 1, S({2,3}));
48 test0(S({1,2,3}), 2, S({1,3}));
49 test0(S({1,2,3}), 3, S({1,2}));
50 test0(S({1,2,3}), 4, S({1,2,3}));
52 test0(S({1,1,1}), 1, S());
53 test0(S({1,1,1}), 2, S({1,1,1}));
54 test0(S({1,1,2}), 1, S({2}));
55 test0(S({1,1,2}), 2, S({1,1}));
56 test0(S({1,1,2}), 3, S({1,1,2}));
57 test0(S({1,2,2}), 1, S({2,2}));
58 test0(S({1,2,2}), 2, S({1}));
59 test0(S({1,2,2}), 3, S({1,2,2}));
61 // Test cross-type erasure
62 using opt = std::optional<typename S::value_type>;
63 test0(S({1,2,1}), opt(), S({1,2,1}));
64 test0(S({1,2,1}), opt(1), S({2}));
65 test0(S({1,2,1}), opt(2), S({1,1}));
66 test0(S({1,2,1}), opt(3), S({1,2,1}));
69 int main(int, char**)
71 test<std::vector<int>>();
72 test<std::vector<int, min_allocator<int>>> ();
73 test<std::vector<int, test_allocator<int>>> ();
75 test<std::vector<long>>();
76 test<std::vector<double>>();
78 return 0;