1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
12 // template <class T, class Allocator, class U>
13 // void erase(vector<T, Allocator>& c, const U& value);
19 #include "test_macros.h"
20 #include "test_allocator.h"
21 #include "min_allocator.h"
23 template <class S
, class U
>
25 test0(S s
, U val
, S expected
)
27 ASSERT_SAME_TYPE(void, decltype(std::erase(s
, val
)));
29 assert(s
== expected
);
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}));
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>>();