1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
13 // template <class T, class Allocator, class Predicate>
14 // void erase_if(list<T, Allocator>& c, Predicate pred);
18 #include "test_macros.h"
19 #include "test_allocator.h"
20 #include "min_allocator.h"
22 template <class S, class Pred>
24 test0(S s, Pred p, S expected)
26 ASSERT_SAME_TYPE(void, decltype(std::erase_if(s, p)));
28 assert(s == expected);
34 auto is1 = [](auto v) { return v == 1;};
35 auto is2 = [](auto v) { return v == 2;};
36 auto is3 = [](auto v) { return v == 3;};
37 auto is4 = [](auto v) { return v == 4;};
38 auto True = [](auto) { return true; };
39 auto False = [](auto) { return false; };
43 test0(S({1}), is1, S());
44 test0(S({1}), is2, S({1}));
46 test0(S({1,2}), is1, S({2}));
47 test0(S({1,2}), is2, S({1}));
48 test0(S({1,2}), is3, S({1,2}));
49 test0(S({1,1}), is1, S());
50 test0(S({1,1}), is3, S({1,1}));
52 test0(S({1,2,3}), is1, S({2,3}));
53 test0(S({1,2,3}), is2, S({1,3}));
54 test0(S({1,2,3}), is3, S({1,2}));
55 test0(S({1,2,3}), is4, S({1,2,3}));
57 test0(S({1,1,1}), is1, S());
58 test0(S({1,1,1}), is2, S({1,1,1}));
59 test0(S({1,1,2}), is1, S({2}));
60 test0(S({1,1,2}), is2, S({1,1}));
61 test0(S({1,1,2}), is3, S({1,1,2}));
62 test0(S({1,2,2}), is1, S({2,2}));
63 test0(S({1,2,2}), is2, S({1}));
64 test0(S({1,2,2}), is3, S({1,2,2}));
66 test0(S({1,2,3}), True, S());
67 test0(S({1,2,3}), False, S({1,2,3}));
72 test<std::list<int>>();
73 test<std::list<int, min_allocator<int>>> ();
74 test<std::list<int, test_allocator<int>>> ();
76 test<std::list<long>>();
77 test<std::list<double>>();