1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <forward_list>
11
12// template <class Predicate> void remove_if(Predicate pred);
13
14#include <forward_list>
15#include <iterator>
16#include <cassert>
17
18#include "min_allocator.h"
19
20bool g(int i)
21{
22    return i < 3;
23}
24
25int main()
26{
27    {
28        typedef int T;
29        typedef std::forward_list<T> C;
30        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
31        const T t2[] = {5, 5, 5};
32        C c1(std::begin(t1), std::end(t1));
33        C c2(std::begin(t2), std::end(t2));
34        c1.remove_if(g);
35        assert(c1 == c2);
36    }
37    {
38        typedef int T;
39        typedef std::forward_list<T> C;
40        const T t1[] = {0, 0, 0, 0};
41        C c1(std::begin(t1), std::end(t1));
42        C c2;
43        c1.remove_if(g);
44        assert(c1 == c2);
45    }
46    {
47        typedef int T;
48        typedef std::forward_list<T> C;
49        const T t1[] = {5, 5, 5};
50        const T t2[] = {5, 5, 5};
51        C c1(std::begin(t1), std::end(t1));
52        C c2(std::begin(t2), std::end(t2));
53        c1.remove_if(g);
54        assert(c1 == c2);
55    }
56    {
57        typedef int T;
58        typedef std::forward_list<T> C;
59        C c1;
60        C c2;
61        c1.remove_if(g);
62        assert(c1 == c2);
63    }
64    {
65        typedef int T;
66        typedef std::forward_list<T> C;
67        const T t1[] = {5, 5, 5, 0};
68        const T t2[] = {5, 5, 5};
69        C c1(std::begin(t1), std::end(t1));
70        C c2(std::begin(t2), std::end(t2));
71        c1.remove_if(g);
72        assert(c1 == c2);
73    }
74#if __cplusplus >= 201103L
75    {
76        typedef int T;
77        typedef std::forward_list<T, min_allocator<T>> C;
78        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
79        const T t2[] = {5, 5, 5};
80        C c1(std::begin(t1), std::end(t1));
81        C c2(std::begin(t2), std::end(t2));
82        c1.remove_if(g);
83        assert(c1 == c2);
84    }
85    {
86        typedef int T;
87        typedef std::forward_list<T, min_allocator<T>> C;
88        const T t1[] = {0, 0, 0, 0};
89        C c1(std::begin(t1), std::end(t1));
90        C c2;
91        c1.remove_if(g);
92        assert(c1 == c2);
93    }
94    {
95        typedef int T;
96        typedef std::forward_list<T, min_allocator<T>> C;
97        const T t1[] = {5, 5, 5};
98        const T t2[] = {5, 5, 5};
99        C c1(std::begin(t1), std::end(t1));
100        C c2(std::begin(t2), std::end(t2));
101        c1.remove_if(g);
102        assert(c1 == c2);
103    }
104    {
105        typedef int T;
106        typedef std::forward_list<T, min_allocator<T>> C;
107        C c1;
108        C c2;
109        c1.remove_if(g);
110        assert(c1 == c2);
111    }
112    {
113        typedef int T;
114        typedef std::forward_list<T, min_allocator<T>> C;
115        const T t1[] = {5, 5, 5, 0};
116        const T t2[] = {5, 5, 5};
117        C c1(std::begin(t1), std::end(t1));
118        C c2(std::begin(t2), std::end(t2));
119        c1.remove_if(g);
120        assert(c1 == c2);
121    }
122#endif
123}
124