3 * Copyright (c) 1996,1997
4 * Silicon Graphics Computer Systems, Inc.
7 * Moscow Center for SPARC Technology
12 * This material is provided "as is", with absolutely no warranty expressed
13 * or implied. Any use is at your own risk.
15 * Permission to use or copy this software for any purpose is hereby granted
16 * without fee, provided the above notices are retained on all copies.
17 * Permission to modify the code and to distribute modified code is granted,
18 * provided the above notices are retained, and a notice that the code was
19 * modified is included with the above copyright notice.
23 /* NOTE: This is an internal header file, included by other STL headers.
24 * You should not attempt to use it directly.
27 #ifndef _STLP_INTERNAL_DBG_SLIST_H
28 #define _STLP_INTERNAL_DBG_SLIST_H
30 #ifndef _STLP_DBG_ITERATOR_H
31 # include <stl/debug/_iterator.h>
34 #define _STLP_NON_DBG_SLIST _STLP_PRIV _STLP_NON_DBG_NAME(slist) <_Tp, _Alloc>
38 #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
39 template <class _Tp, class _Alloc>
41 value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&)
44 template <class _Tp, class _Alloc>
45 inline forward_iterator_tag
46 iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&)
47 { return forward_iterator_tag(); }
50 _STLP_MOVE_TO_PRIV_NAMESPACE
53 * slist special debug traits version.
55 template <class _Traits>
56 struct _SlistDbgTraits : _Traits {
57 typedef _SlistDbgTraits<typename _Traits::_ConstTraits> _ConstTraits;
58 typedef _SlistDbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits;
61 * We don't want the before_begin iterator to return false at _Dereferenceable
62 * call to do not break the current debug framework but calling * operator should
65 template <class _Iterator>
66 static bool _Check(const _Iterator& __it)
67 { return !(__it._M_iterator == (__it._Get_container_ptr())->before_begin()); }
70 _STLP_MOVE_TO_STD_NAMESPACE
72 template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
74 #if !defined (__DMC__)
77 _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST >
78 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
79 , public __stlport_class<slist<_Tp, _Alloc> >
83 typedef _STLP_NON_DBG_SLIST _Base;
84 typedef slist<_Tp,_Alloc> _Self;
85 typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST > _ConstructCheck;
89 __IMPORT_CONTAINER_TYPEDEFS(_Base)
91 typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Nonconst_traits<value_type> > > iterator;
92 typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Const_traits<value_type> > > const_iterator;
94 allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
96 _Base _M_non_dbg_impl;
97 _STLP_PRIV __owned_list _M_iter_list;
99 void _Invalidate_iterator(const iterator& __it)
100 { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
101 void _Invalidate_iterators(const iterator& __first, const iterator& __last)
102 { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
104 typedef typename _Base::iterator _Base_iterator;
107 explicit slist(const allocator_type& __a = allocator_type())
108 : _M_non_dbg_impl(__a) , _M_iter_list(&_M_non_dbg_impl) {}
110 #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
111 explicit slist(size_type __n, const value_type& __x = _Tp(),
113 slist(size_type __n, const value_type& __x,
114 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
115 const allocator_type& __a = allocator_type())
116 : _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
118 #if defined(_STLP_DONT_SUP_DFLT_PARAM)
119 explicit slist(size_type __n) : _M_non_dbg_impl(__n) , _M_iter_list(&_M_non_dbg_impl) {}
120 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
122 slist(__move_source<_Self> src)
123 : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
124 _M_iter_list(&_M_non_dbg_impl) {
125 #if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
126 src.get()._M_iter_list._Invalidate_all();
128 src.get()._M_iter_list._Set_owner(_M_iter_list);
132 #if defined (_STLP_MEMBER_TEMPLATES)
133 // We don't need any dispatching tricks here, because _M_insert_after_range
134 // already does them.
135 template <class _InputIterator>
136 slist(_InputIterator __first, _InputIterator __last,
137 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
138 : _ConstructCheck(__first, __last),
139 _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
140 _M_iter_list(&_M_non_dbg_impl) {}
141 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
142 template <class _InputIterator>
143 slist(_InputIterator __first, _InputIterator __last)
144 : _ConstructCheck(__first, __last),
145 _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
146 _M_iter_list(&_M_non_dbg_impl) {}
150 slist(const value_type* __first, const value_type* __last,
151 const allocator_type& __a = allocator_type())
152 : _ConstructCheck(__first, __last),
153 _M_non_dbg_impl(__first, __last, __a),
154 _M_iter_list(&_M_non_dbg_impl) {}
156 slist(const_iterator __first, const_iterator __last,
157 const allocator_type& __a = allocator_type() )
158 : _ConstructCheck(__first, __last),
159 _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
160 _M_iter_list(&_M_non_dbg_impl) {}
163 slist(const _Self& __x) :
164 _ConstructCheck(__x),
165 _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
167 _Self& operator= (const _Self& __x) {
169 _Invalidate_iterators(begin(), end());
170 _M_non_dbg_impl = __x._M_non_dbg_impl;
177 void assign(size_type __n, const value_type& __val) {
178 _Invalidate_iterators(begin(), end());
179 _M_non_dbg_impl.assign(__n, __val);
182 iterator before_begin()
183 { return iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); }
184 const_iterator before_begin() const
185 { return const_iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); }
188 { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
189 const_iterator begin() const
190 { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin());}
193 { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
194 const_iterator end() const
195 { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
197 bool empty() const { return _M_non_dbg_impl.empty(); }
198 size_type size() const { return _M_non_dbg_impl.size(); }
199 size_type max_size() const { return _M_non_dbg_impl.max_size(); }
201 void swap(_Self& __x) {
202 _M_iter_list._Swap_owners(__x._M_iter_list);
203 _M_non_dbg_impl.swap(__x._M_non_dbg_impl);
207 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
208 return _M_non_dbg_impl.front();
210 const_reference front() const {
211 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
212 return _M_non_dbg_impl.front();
214 void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); }
216 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
217 _M_non_dbg_impl.pop_front();
219 iterator previous(const_iterator __pos) {
220 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
221 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
222 return iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator));
224 const_iterator previous(const_iterator __pos) const {
225 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
226 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
227 return const_iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator));
232 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
233 iterator insert_after(iterator __pos, const value_type& __x = _Tp()) {
235 iterator insert_after(iterator __pos, const value_type& __x) {
236 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
237 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
238 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
239 return iterator(&_M_iter_list,_M_non_dbg_impl.insert_after(__pos._M_iterator, __x));
242 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
243 iterator insert_after(iterator __pos) {
244 return insert_after(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
246 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
248 void insert_after(iterator __pos, size_type __n, const value_type& __x) {
249 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
250 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
251 _M_non_dbg_impl.insert_after(__pos._M_iterator, __n, __x);
254 #if defined (_STLP_MEMBER_TEMPLATES)
255 template <class _InputIterator>
256 void assign(_InputIterator __first, _InputIterator __last) {
257 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
258 _Invalidate_iterators(begin(), end());
259 _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
262 void assign(const_iterator __first, const_iterator __last) {
263 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
264 _Invalidate_iterators(begin(), end());
265 _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
267 void assign(const value_type *__first, const value_type *__last) {
268 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
269 _Invalidate_iterators(begin(), end());
270 _M_non_dbg_impl.assign(__first, __last);
274 #if defined (_STLP_MEMBER_TEMPLATES)
275 template <class _InIter>
276 void insert_after(iterator __pos, _InIter __first, _InIter __last) {
277 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
278 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
279 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
280 _M_non_dbg_impl.insert_after(__pos._M_iterator,
281 _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
284 template <class _InIter>
285 void insert(iterator __pos, _InIter __first, _InIter __last) {
286 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
287 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
288 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
289 _M_non_dbg_impl.insert(__pos._M_iterator,
290 _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
293 void insert_after(iterator __pos,
294 const_iterator __first, const_iterator __last) {
295 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
296 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
297 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
298 _M_non_dbg_impl.insert_after(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
300 void insert_after(iterator __pos,
301 const value_type* __first, const value_type* __last) {
302 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
303 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
304 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
305 _M_non_dbg_impl.insert_after(__pos._M_iterator, __first, __last);
308 void insert(iterator __pos, const_iterator __first, const_iterator __last) {
309 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
310 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
311 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
312 _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
314 void insert(iterator __pos, const value_type* __first,
315 const value_type* __last) {
316 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
317 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
318 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
319 _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
323 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
324 iterator insert(iterator __pos, const value_type& __x = _Tp()) {
326 iterator insert(iterator __pos, const value_type& __x) {
327 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
328 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
329 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
330 return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
333 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
334 iterator insert(iterator __pos) {
335 return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
337 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
339 void insert(iterator __pos, size_type __n, const value_type& __x) {
340 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
341 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
342 _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
346 iterator erase_after(iterator __pos) {
347 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
348 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
349 iterator __tmp = __pos; ++__tmp;
350 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp))
351 _Invalidate_iterator(__tmp);
352 return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__pos._M_iterator));
354 iterator erase_after(iterator __before_first, iterator __last) {
355 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first))
356 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __last, begin(), end()))
357 iterator __tmp = __before_first; ++__tmp;
358 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp))
359 _Invalidate_iterators(__tmp, __last);
360 return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__before_first._M_iterator, __last._M_iterator));
363 iterator erase(iterator __pos) {
364 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
365 _STLP_VERBOSE_ASSERT(__pos._M_iterator != _M_non_dbg_impl.before_begin(), _StlMsg_INVALID_ARGUMENT)
366 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
367 _Invalidate_iterator(__pos);
368 return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
370 iterator erase(iterator __first, iterator __last) {
371 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
372 _Invalidate_iterators(__first, __last);
373 return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
376 #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
377 void resize(size_type __new_size, const value_type& __x = _Tp()) {
379 void resize(size_type __new_size, const value_type& __x) {
380 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
381 _M_non_dbg_impl.resize(__new_size, __x);
384 #if defined(_STLP_DONT_SUP_DFLT_PARAM)
385 void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
386 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
389 _Invalidate_iterators(begin(), end());
390 _M_non_dbg_impl.clear();
394 // Removes all of the elements from the list __x to *this, inserting
395 // them immediately after __pos. __x must not be *this. Complexity:
396 // linear in __x.size().
397 void splice_after(iterator __pos, _Self& __x) {
398 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
399 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
400 _STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT)
401 _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl);
402 if (get_allocator() == __x.get_allocator()) {
403 __x._M_iter_list._Set_owner(_M_iter_list);
406 __x._Invalidate_iterators(__x.begin(), __x.end());
410 // Moves the element that follows __prev to *this, inserting it immediately
411 // after __pos. This is constant time.
412 void splice_after(iterator __pos, _Self& __x, iterator __prev) {
413 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
414 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
415 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__prev))
416 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __prev))
417 iterator __elem = __prev; ++__elem;
418 _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl, __prev._M_iterator);
419 if (get_allocator() == __x.get_allocator()) {
420 _STLP_PRIV __change_ite_owner(__elem, &_M_iter_list);
423 __x._Invalidate_iterator(__elem);
427 // Moves the range [__before_first + 1, __before_last + 1) to *this,
428 // inserting it immediately after __pos. This is constant time.
429 void splice_after(iterator __pos, _Self& __x,
430 iterator __before_first, iterator __before_last) {
431 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
432 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
433 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __before_last))
434 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __before_first))
435 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first))
436 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_last))
437 iterator __first = __before_first; ++__first;
438 iterator __last = __before_last; ++__last;
439 if (get_allocator() == __x.get_allocator()) {
440 _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
443 __x._Invalidate_iterators(__first, __last);
445 _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl,
446 __before_first._M_iterator, __before_last._M_iterator);
449 // Linear in distance(begin(), __pos), and linear in __x.size().
450 void splice(iterator __pos, _Self& __x) {
451 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
452 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
453 _STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT)
454 _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl);
455 if (get_allocator() == __x.get_allocator()) {
456 __x._M_iter_list._Set_owner(_M_iter_list);
459 __x._Invalidate_iterators(__x.begin(), __x.end());
463 // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i).
464 void splice(iterator __pos, _Self& __x, iterator __i) {
465 //__pos should be owned by *this and not be the before_begin iterator
466 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
467 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
468 //__i should be dereferenceable, not before_begin and be owned by __x
469 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i))
470 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list ,__i))
471 _STLP_VERBOSE_ASSERT(!(__i == __x.before_begin()), _StlMsg_INVALID_ARGUMENT)
472 if (get_allocator() == __x.get_allocator()) {
473 _STLP_PRIV __change_ite_owner(__i, &_M_iter_list);
476 __x._Invalidate_iterator(__i);
478 _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator);
481 // Linear in distance(begin(), __pos), in distance(__x.begin(), __first),
482 // and in distance(__first, __last).
483 void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
484 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
485 _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
486 //_STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
487 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end()))
488 if (get_allocator() == __x.get_allocator()) {
489 _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
492 __x._Invalidate_iterators(__first, __last);
494 _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl,
495 __first._M_iterator, __last._M_iterator);
499 { _M_non_dbg_impl.reverse(); }
501 void remove(const value_type& __val) {
502 _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
503 while (__first != __last) {
504 _Base_iterator __next = __first;
506 if (__val == *__first) {
507 _Invalidate_iterator(iterator(&_M_iter_list, __first));
508 _M_non_dbg_impl.erase(__first);
514 _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
515 if (__first == __last) return;
516 _Base_iterator __next = __first;
517 while (++__next != __last) {
518 if (*__first == *__next) {
519 _Invalidate_iterator(iterator(&_M_iter_list, __next));
520 _M_non_dbg_impl.erase(__next);
527 void merge(_Self& __x) {
528 _STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
529 #if !defined (_STLP_NO_EXTENSIONS)
530 /* comments below due to bug in GCC compilers: ones eat all memory and die if see
531 * something like namespace_name::func_name() - ptr
533 _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end()))
534 _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator))
536 _M_non_dbg_impl.merge(__x._M_non_dbg_impl);
537 if (get_allocator() == __x.get_allocator()) {
538 __x._M_iter_list._Set_owner(_M_iter_list);
541 __x._Invalidate_iterators(__x.begin(), __x.end());
545 _M_non_dbg_impl.sort();
548 #if defined (_STLP_MEMBER_TEMPLATES)
549 template <class _Predicate>
550 void remove_if(_Predicate __pred) {
551 _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
552 while (__first != __last) {
553 _Base_iterator __next = __first;
555 if (__pred(*__first)) {
556 _Invalidate_iterator(iterator(&_M_iter_list, __first));
557 _M_non_dbg_impl.erase(__first);
563 template <class _BinaryPredicate>
564 void unique(_BinaryPredicate __pred) {
565 _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
566 if (__first == __last) return;
567 _Base_iterator __next = __first;
568 while (++__next != __last) {
569 if (__binary_pred(*__first, *__next)) {
570 _Invalidate_iterator(iterator(&_M_iter_list, __next));
571 _M_non_dbg_impl.erase(__next);
579 template <class _StrictWeakOrdering>
580 void merge(_Self& __x, _StrictWeakOrdering __ord) {
581 _STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
582 #if !defined (_STLP_NO_EXTENSIONS)
583 /* comments below due to bug in GCC compilers: ones eat all memory and die if see
584 * something like namespace_name::func_name() - ptr
586 _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __ord))
587 _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __ord))
589 _M_non_dbg_impl.merge(__x._M_non_dbg_impl, __ord);
590 if (get_allocator() == __x.get_allocator()) {
591 __x._M_iter_list._Set_owner(_M_iter_list);
594 __x._Invalidate_iterators(__x.begin(), __x.end());
598 template <class _StrictWeakOrdering>
599 void sort(_StrictWeakOrdering __comp)
600 { _M_non_dbg_impl.sort(__comp); }
606 #undef _STLP_NON_DBG_SLIST
608 #endif /* _STLP_INTERNAL_DBG_SLIST_H */