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 //===----------------------------------------------------------------------===//
12 // void remove(const value_type& v);
14 #include <forward_list>
18 #include "min_allocator.h"
21 S(int i) : i_(new int(i)) {}
22 S(const S &rhs) : i_(new int(*rhs.i_)) {}
23 S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
24 ~S () { delete i_; i_ = NULL; }
25 bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
26 int get () const { return *i_; }
35 typedef std::forward_list<T> C;
36 const T t1[] = {0, 5, 5, 0, 0, 0, 5};
37 const T t2[] = {5, 5, 5};
38 C c1(std::begin(t1), std::end(t1));
39 C c2(std::begin(t2), std::end(t2));
45 typedef std::forward_list<T> C;
46 const T t1[] = {0, 0, 0, 0};
47 C c1(std::begin(t1), std::end(t1));
54 typedef std::forward_list<T> C;
55 const T t1[] = {5, 5, 5};
56 const T t2[] = {5, 5, 5};
57 C c1(std::begin(t1), std::end(t1));
58 C c2(std::begin(t2), std::end(t2));
64 typedef std::forward_list<T> C;
72 typedef std::forward_list<T> C;
73 const T t1[] = {5, 5, 5, 0};
74 const T t2[] = {5, 5, 5};
75 C c1(std::begin(t1), std::end(t1));
76 C c2(std::begin(t2), std::end(t2));
82 typedef std::forward_list<T> C;
83 int t1[] = {1, 2, 1, 3, 5, 8, 11};
84 int t2[] = { 2, 3, 5, 8, 11};
85 C c1(std::begin(t1), std::end(t1));
86 C c2(std::begin(t2), std::end(t2));
87 c1.remove(c1.front());
92 typedef std::forward_list<T> C;
93 int t1[] = {1, 2, 1, 3, 5, 8, 11, 1};
94 int t2[] = { 2, 3, 5, 8, 11 };
96 for(int *ip = std::end(t1); ip != std::begin(t1);)
97 c.push_front(S(*--ip));
99 C::const_iterator it = c.begin();
100 for(int *ip = std::begin(t2); ip != std::end(t2); ++ip, ++it) {
101 assert ( it != c.end());
102 assert ( *ip == it->get());
104 assert ( it == c.end ());
106 #if __cplusplus >= 201103L
109 typedef std::forward_list<T, min_allocator<T>> C;
110 const T t1[] = {0, 5, 5, 0, 0, 0, 5};
111 const T t2[] = {5, 5, 5};
112 C c1(std::begin(t1), std::end(t1));
113 C c2(std::begin(t2), std::end(t2));
119 typedef std::forward_list<T, min_allocator<T>> C;
120 const T t1[] = {0, 0, 0, 0};
121 C c1(std::begin(t1), std::end(t1));
128 typedef std::forward_list<T, min_allocator<T>> C;
129 const T t1[] = {5, 5, 5};
130 const T t2[] = {5, 5, 5};
131 C c1(std::begin(t1), std::end(t1));
132 C c2(std::begin(t2), std::end(t2));
138 typedef std::forward_list<T, min_allocator<T>> C;
146 typedef std::forward_list<T, min_allocator<T>> C;
147 const T t1[] = {5, 5, 5, 0};
148 const T t2[] = {5, 5, 5};
149 C c1(std::begin(t1), std::end(t1));
150 C c2(std::begin(t2), std::end(t2));