61 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
63 template<
typename _Tp,
typename _Alloc>
65 _List_base<_Tp, _Alloc>::
68 typedef _List_node<_Tp> _Node;
69 _Node* __cur =
static_cast<_Node*
>(_M_impl._M_node._M_next);
70 while (__cur != &_M_impl._M_node)
73 __cur =
static_cast<_Node*
>(__cur->_M_next);
74 #if __cplusplus >= 201103L
75 _M_get_Node_allocator().destroy(__tmp);
77 _M_get_Tp_allocator().destroy(std::__addressof(__tmp->_M_data));
83 #if __cplusplus >= 201103L
84 template<
typename _Tp,
typename _Alloc>
85 template<
typename... _Args>
86 typename list<_Tp, _Alloc>::iterator
88 emplace(iterator __position, _Args&&... __args)
90 _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
91 __tmp->_M_hook(__position._M_node);
92 return iterator(__tmp);
96 template<
typename _Tp,
typename _Alloc>
97 typename list<_Tp, _Alloc>::iterator
99 insert(iterator __position,
const value_type& __x)
101 _Node* __tmp = _M_create_node(__x);
102 __tmp->_M_hook(__position._M_node);
103 return iterator(__tmp);
106 template<
typename _Tp,
typename _Alloc>
107 typename list<_Tp, _Alloc>::iterator
109 erase(iterator __position)
111 iterator __ret = iterator(__position._M_node->_M_next);
112 _M_erase(__position);
116 #if __cplusplus >= 201103L
117 template<
typename _Tp,
typename _Alloc>
120 _M_default_append(size_type __n)
125 for (; __i < __n; ++__i)
136 template<
typename _Tp,
typename _Alloc>
139 resize(size_type __new_size)
141 iterator __i = begin();
143 for (; __i != end() && __len < __new_size; ++__i, ++__len)
145 if (__len == __new_size)
148 _M_default_append(__new_size - __len);
151 template<
typename _Tp,
typename _Alloc>
154 resize(size_type __new_size,
const value_type& __x)
156 iterator __i = begin();
158 for (; __i != end() && __len < __new_size; ++__i, ++__len)
160 if (__len == __new_size)
163 insert(end(), __new_size - __len, __x);
166 template<
typename _Tp,
typename _Alloc>
169 resize(size_type __new_size, value_type __x)
171 iterator __i = begin();
173 for (; __i != end() && __len < __new_size; ++__i, ++__len)
175 if (__len == __new_size)
178 insert(end(), __new_size - __len, __x);
182 template<
typename _Tp,
typename _Alloc>
185 operator=(
const list& __x)
189 iterator __first1 = begin();
190 iterator __last1 = end();
191 const_iterator __first2 = __x.begin();
192 const_iterator __last2 = __x.end();
193 for (; __first1 != __last1 && __first2 != __last2;
194 ++__first1, ++__first2)
195 *__first1 = *__first2;
196 if (__first2 == __last2)
197 erase(__first1, __last1);
199 insert(__last1, __first2, __last2);
204 template<
typename _Tp,
typename _Alloc>
207 _M_fill_assign(size_type __n,
const value_type& __val)
209 iterator __i = begin();
210 for (; __i != end() && __n > 0; ++__i, --__n)
213 insert(end(), __n, __val);
218 template<
typename _Tp,
typename _Alloc>
219 template <
typename _InputIterator>
222 _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
225 iterator __first1 = begin();
226 iterator __last1 = end();
227 for (; __first1 != __last1 && __first2 != __last2;
228 ++__first1, ++__first2)
229 *__first1 = *__first2;
230 if (__first2 == __last2)
231 erase(__first1, __last1);
233 insert(__last1, __first2, __last2);
236 template<
typename _Tp,
typename _Alloc>
239 remove(
const value_type& __value)
241 iterator __first = begin();
242 iterator __last = end();
243 iterator __extra = __last;
244 while (__first != __last)
246 iterator __next = __first;
248 if (*__first == __value)
253 if (std::__addressof(*__first) != std::__addressof(__value))
260 if (__extra != __last)
264 template<
typename _Tp,
typename _Alloc>
269 iterator __first = begin();
270 iterator __last = end();
271 if (__first == __last)
273 iterator __next = __first;
274 while (++__next != __last)
276 if (*__first == *__next)
284 template<
typename _Tp,
typename _Alloc>
287 #if __cplusplus >= 201103L
297 _M_check_equal_allocators(__x);
299 iterator __first1 = begin();
300 iterator __last1 = end();
301 iterator __first2 = __x.begin();
302 iterator __last2 = __x.end();
303 while (__first1 != __last1 && __first2 != __last2)
304 if (*__first2 < *__first1)
306 iterator __next = __first2;
307 _M_transfer(__first1, __first2, ++__next);
312 if (__first2 != __last2)
313 _M_transfer(__last1, __first2, __last2);
317 template<
typename _Tp,
typename _Alloc>
318 template <
typename _StrictWeakOrdering>
321 #if __cplusplus >= 201103L
322 merge(list&& __x, _StrictWeakOrdering __comp)
324 merge(list& __x, _StrictWeakOrdering __comp)
331 _M_check_equal_allocators(__x);
333 iterator __first1 = begin();
334 iterator __last1 = end();
335 iterator __first2 = __x.begin();
336 iterator __last2 = __x.end();
337 while (__first1 != __last1 && __first2 != __last2)
338 if (__comp(*__first2, *__first1))
340 iterator __next = __first2;
341 _M_transfer(__first1, __first2, ++__next);
346 if (__first2 != __last2)
347 _M_transfer(__last1, __first2, __last2);
351 template<
typename _Tp,
typename _Alloc>
357 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
358 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
362 list * __fill = &__tmp[0];
367 __carry.splice(__carry.begin(), *
this, begin());
369 for(__counter = &__tmp[0];
370 __counter != __fill && !__counter->empty();
373 __counter->merge(__carry);
374 __carry.swap(*__counter);
376 __carry.swap(*__counter);
377 if (__counter == __fill)
382 for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
383 __counter->merge(*(__counter - 1));
384 swap( *(__fill - 1) );
388 template<
typename _Tp,
typename _Alloc>
389 template <
typename _Predicate>
392 remove_if(_Predicate __pred)
394 iterator __first = begin();
395 iterator __last = end();
396 while (__first != __last)
398 iterator __next = __first;
400 if (__pred(*__first))
406 template<
typename _Tp,
typename _Alloc>
407 template <
typename _BinaryPredicate>
410 unique(_BinaryPredicate __binary_pred)
412 iterator __first = begin();
413 iterator __last = end();
414 if (__first == __last)
416 iterator __next = __first;
417 while (++__next != __last)
419 if (__binary_pred(*__first, *__next))
427 template<
typename _Tp,
typename _Alloc>
428 template <
typename _StrictWeakOrdering>
431 sort(_StrictWeakOrdering __comp)
434 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
435 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
439 list * __fill = &__tmp[0];
444 __carry.splice(__carry.begin(), *
this, begin());
446 for(__counter = &__tmp[0];
447 __counter != __fill && !__counter->empty();
450 __counter->merge(__carry, __comp);
451 __carry.swap(*__counter);
453 __carry.swap(*__counter);
454 if (__counter == __fill)
459 for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
460 __counter->merge(*(__counter - 1), __comp);
465 _GLIBCXX_END_NAMESPACE_CONTAINER
#define __try
Definition: exception_defines.h:35
#define __throw_exception_again
Definition: exception_defines.h:37
#define __catch(X)
Definition: exception_defines.h:36
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160