/home/ntakagi/work/STLport-5.1.5/stlport/stl/debug/_slist.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1996,1997
00004  * Silicon Graphics Computer Systems, Inc.
00005  *
00006  * Copyright (c) 1997
00007  * Moscow Center for SPARC Technology
00008  *
00009  * Copyright (c) 1999
00010  * Boris Fomitchev
00011  *
00012  * This material is provided "as is", with absolutely no warranty expressed
00013  * or implied. Any use is at your own risk.
00014  *
00015  * Permission to use or copy this software for any purpose is hereby granted
00016  * without fee, provided the above notices are retained on all copies.
00017  * Permission to modify the code and to distribute modified code is granted,
00018  * provided the above notices are retained, and a notice that the code was
00019  * modified is included with the above copyright notice.
00020  *
00021  */
00022 
00023 /* NOTE: This is an internal header file, included by other STL headers.
00024  *   You should not attempt to use it directly.
00025  */
00026 
00027 #ifndef _STLP_INTERNAL_DBG_SLIST_H
00028 #define _STLP_INTERNAL_DBG_SLIST_H
00029 
00030 #ifndef _STLP_DBG_ITERATOR_H
00031 #  include <stl/debug/_iterator.h>
00032 #endif
00033 
00034 #define _STLP_NON_DBG_SLIST _STLP_PRIV _STLP_NON_DBG_NAME(slist) <_Tp, _Alloc>
00035 
00036 _STLP_BEGIN_NAMESPACE
00037 
00038 #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
00039 template <class _Tp, class _Alloc>
00040 inline _Tp*
00041 value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&)
00042 { return (_Tp*)0; }
00043 
00044 template <class _Tp, class _Alloc>
00045 inline forward_iterator_tag
00046 iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&)
00047 { return forward_iterator_tag(); }
00048 #endif
00049 
00050 _STLP_MOVE_TO_PRIV_NAMESPACE
00051 
00052 /*
00053  * slist special debug traits version.
00054  */
00055 template <class _Traits>
00056 struct _SlistDbgTraits : _Traits {
00057   typedef _SlistDbgTraits<typename _Traits::_ConstTraits> _ConstTraits;
00058   typedef _SlistDbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits;
00059 
00060   /*
00061    * We don't want the before_begin iterator to return false at _Dereferenceable
00062    * call to do not break the current debug framework but calling * operator should
00063    * fail.
00064    */
00065   template <class _Iterator>
00066   static bool _Check(const _Iterator& __it)
00067   { return !(__it._M_iterator == (__it._Get_container_ptr())->before_begin()); }
00068 };
00069 
00070 _STLP_MOVE_TO_STD_NAMESPACE
00071 
00072 template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
00073 class slist :
00074 #if !defined (__DMC__)
00075              private
00076 #endif
00077                      _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST >
00078 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
00079             , public __stlport_class<slist<_Tp, _Alloc> >
00080 #endif
00081 {
00082 private:
00083   typedef _STLP_NON_DBG_SLIST _Base;
00084   typedef slist<_Tp,_Alloc> _Self;
00085   typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST > _ConstructCheck;
00086 
00087 public:
00088 
00089   __IMPORT_CONTAINER_TYPEDEFS(_Base)
00090 
00091   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Nonconst_traits<value_type> > > iterator;
00092   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Const_traits<value_type> > >    const_iterator;
00093 
00094   allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
00095 private:
00096   _Base _M_non_dbg_impl;
00097   _STLP_PRIV __owned_list _M_iter_list;
00098 
00099   void _Invalidate_iterator(const iterator& __it)
00100   { _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
00101   void _Invalidate_iterators(const iterator& __first, const iterator& __last)
00102   { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
00103 
00104   typedef typename _Base::iterator _Base_iterator;
00105 
00106 public:
00107   explicit slist(const allocator_type& __a = allocator_type())
00108     : _M_non_dbg_impl(__a) , _M_iter_list(&_M_non_dbg_impl) {}
00109 
00110 #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
00111   explicit slist(size_type __n, const value_type& __x = _Tp(),
00112 #else
00113   slist(size_type __n, const value_type& __x,
00114 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00115         const allocator_type& __a =  allocator_type())
00116     : _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
00117 
00118 #if defined(_STLP_DONT_SUP_DFLT_PARAM)
00119   explicit slist(size_type __n) : _M_non_dbg_impl(__n) , _M_iter_list(&_M_non_dbg_impl) {}
00120 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00121 
00122   slist(__move_source<_Self> src)
00123     : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
00124       _M_iter_list(&_M_non_dbg_impl) {
00125 #if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
00126     src.get()._M_iter_list._Invalidate_all();
00127 #else
00128     src.get()._M_iter_list._Set_owner(_M_iter_list);
00129 #endif
00130   }
00131 
00132 #if defined (_STLP_MEMBER_TEMPLATES)
00133   // We don't need any dispatching tricks here, because _M_insert_after_range
00134   // already does them.
00135   template <class _InputIterator>
00136   slist(_InputIterator __first, _InputIterator __last,
00137         const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
00138     : _ConstructCheck(__first, __last),
00139       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
00140       _M_iter_list(&_M_non_dbg_impl) {}
00141 #  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
00142   template <class _InputIterator>
00143   slist(_InputIterator __first, _InputIterator __last)
00144     : _ConstructCheck(__first, __last),
00145       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
00146       _M_iter_list(&_M_non_dbg_impl) {}
00147 #  endif
00148 #else
00149 
00150   slist(const value_type* __first, const value_type* __last,
00151         const allocator_type& __a =  allocator_type())
00152     : _ConstructCheck(__first, __last),
00153       _M_non_dbg_impl(__first, __last, __a),
00154       _M_iter_list(&_M_non_dbg_impl) {}
00155 
00156   slist(const_iterator __first, const_iterator __last,
00157         const allocator_type& __a = allocator_type() )
00158     : _ConstructCheck(__first, __last),
00159       _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
00160       _M_iter_list(&_M_non_dbg_impl) {}
00161 #endif
00162 
00163   slist(const _Self& __x) :
00164     _ConstructCheck(__x),
00165     _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
00166 
00167   _Self& operator= (const _Self& __x) {
00168     if (this != &__x) {
00169       _Invalidate_iterators(begin(), end());
00170       _M_non_dbg_impl = __x._M_non_dbg_impl;
00171     }
00172     return *this;
00173   }
00174 
00175   ~slist() {}
00176 
00177   void assign(size_type __n, const value_type& __val) {
00178     _Invalidate_iterators(begin(), end());
00179     _M_non_dbg_impl.assign(__n, __val);
00180   }
00181 
00182   iterator before_begin()
00183   { return iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); }
00184   const_iterator before_begin() const
00185   { return const_iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); }
00186 
00187   iterator begin()
00188   { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
00189   const_iterator begin() const
00190   { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin());}
00191 
00192   iterator end()
00193   { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
00194   const_iterator end() const
00195   { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
00196 
00197   bool empty() const { return _M_non_dbg_impl.empty(); }
00198   size_type size() const { return _M_non_dbg_impl.size(); }
00199   size_type max_size() const { return _M_non_dbg_impl.max_size(); }
00200 
00201   void swap(_Self& __x) {
00202     _M_iter_list._Swap_owners(__x._M_iter_list);
00203     _M_non_dbg_impl.swap(__x._M_non_dbg_impl);
00204   }
00205 
00206   reference front() {
00207     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
00208     return _M_non_dbg_impl.front();
00209   }
00210   const_reference front() const {
00211     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
00212     return _M_non_dbg_impl.front();
00213   }
00214   void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); }
00215   void pop_front() {
00216     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
00217     _M_non_dbg_impl.pop_front();
00218   }
00219   iterator previous(const_iterator __pos) {
00220     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00221     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00222     return iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator));
00223   }
00224   const_iterator previous(const_iterator __pos) const {
00225     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00226     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00227     return const_iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator));
00228   }
00229 
00230 public:
00231 
00232 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
00233   iterator insert_after(iterator __pos, const value_type& __x = _Tp()) {
00234 #else
00235   iterator insert_after(iterator __pos, const value_type& __x) {
00236 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00237     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00238     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00239     return iterator(&_M_iter_list,_M_non_dbg_impl.insert_after(__pos._M_iterator, __x));
00240   }
00241 
00242 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
00243   iterator insert_after(iterator __pos) {
00244     return insert_after(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
00245   }
00246 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00247 
00248   void insert_after(iterator __pos, size_type __n, const value_type& __x) {
00249     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00250     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00251     _M_non_dbg_impl.insert_after(__pos._M_iterator, __n, __x);
00252   }
00253 
00254 #if defined (_STLP_MEMBER_TEMPLATES)
00255   template <class _InputIterator>
00256   void assign(_InputIterator __first, _InputIterator __last) {
00257     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00258     _Invalidate_iterators(begin(), end());
00259     _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
00260   }
00261 #else
00262   void assign(const_iterator __first, const_iterator __last) {
00263     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00264     _Invalidate_iterators(begin(), end());
00265     _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
00266   }
00267   void assign(const value_type *__first, const value_type *__last) {
00268     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
00269     _Invalidate_iterators(begin(), end());
00270     _M_non_dbg_impl.assign(__first, __last);
00271   }
00272 #endif
00273 
00274 #if defined (_STLP_MEMBER_TEMPLATES)
00275   template <class _InIter>
00276   void insert_after(iterator __pos, _InIter __first, _InIter __last) {
00277     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00278     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00279     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00280     _M_non_dbg_impl.insert_after(__pos._M_iterator,
00281                                  _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
00282   }
00283 
00284   template <class _InIter>
00285   void insert(iterator __pos, _InIter __first, _InIter __last) {
00286     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00287     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00288     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00289     _M_non_dbg_impl.insert(__pos._M_iterator,
00290                            _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
00291   }
00292 #else
00293   void insert_after(iterator __pos,
00294                     const_iterator __first, const_iterator __last) {
00295     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00296     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00297     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00298     _M_non_dbg_impl.insert_after(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
00299   }
00300   void insert_after(iterator __pos,
00301                     const value_type* __first, const value_type* __last) {
00302     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00303     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00304     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
00305     _M_non_dbg_impl.insert_after(__pos._M_iterator, __first, __last);
00306   }
00307 
00308   void insert(iterator __pos, const_iterator __first, const_iterator __last) {
00309     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00310     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00311     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
00312     _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
00313   }
00314   void insert(iterator __pos, const value_type* __first,
00315                               const value_type* __last) {
00316     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00317     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00318     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
00319     _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
00320   }
00321 #endif
00322 
00323 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
00324   iterator insert(iterator __pos, const value_type& __x = _Tp()) {
00325 #else
00326   iterator insert(iterator __pos, const value_type& __x) {
00327 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00328     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00329     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00330     return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
00331   }
00332 
00333 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
00334   iterator insert(iterator __pos) {
00335     return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
00336   }
00337 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00338 
00339   void insert(iterator __pos, size_type __n, const value_type& __x) {
00340     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00341     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00342     _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
00343   }
00344 
00345 public:
00346   iterator erase_after(iterator __pos) {
00347     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00348     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00349     iterator __tmp = __pos; ++__tmp;
00350     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp))
00351     _Invalidate_iterator(__tmp);
00352     return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__pos._M_iterator));
00353   }
00354   iterator erase_after(iterator __before_first, iterator __last) {
00355     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first))
00356     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __last, begin(), end()))
00357     iterator __tmp = __before_first; ++__tmp;
00358     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp))
00359     _Invalidate_iterators(__tmp, __last);
00360     return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__before_first._M_iterator, __last._M_iterator));
00361   }
00362 
00363   iterator erase(iterator __pos) {
00364     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00365     _STLP_VERBOSE_ASSERT(__pos._M_iterator != _M_non_dbg_impl.before_begin(), _StlMsg_INVALID_ARGUMENT)
00366     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00367     _Invalidate_iterator(__pos);
00368     return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
00369   }
00370   iterator erase(iterator __first, iterator __last) {
00371     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
00372     _Invalidate_iterators(__first, __last);
00373     return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
00374   }
00375 
00376 #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
00377   void resize(size_type __new_size, const value_type& __x = _Tp()) {
00378 #else
00379   void resize(size_type __new_size, const value_type& __x) {
00380 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00381     _M_non_dbg_impl.resize(__new_size, __x);
00382   }
00383 
00384 #if defined(_STLP_DONT_SUP_DFLT_PARAM)
00385   void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
00386 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00387 
00388   void clear() {
00389     _Invalidate_iterators(begin(), end());
00390     _M_non_dbg_impl.clear();
00391   }
00392 
00393 public:
00394   // Removes all of the elements from the list __x to *this, inserting
00395   // them immediately after __pos.  __x must not be *this.  Complexity:
00396   // linear in __x.size().
00397   void splice_after(iterator __pos, _Self& __x) {
00398     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00399     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00400     _STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT)
00401     _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl);
00402     if (get_allocator() == __x.get_allocator()) {
00403       __x._M_iter_list._Set_owner(_M_iter_list);
00404     }
00405     else {
00406       __x._Invalidate_iterators(__x.begin(), __x.end());
00407     }
00408   }
00409 
00410   // Moves the element that follows __prev to *this, inserting it immediately
00411   //  after __pos.  This is constant time.
00412   void splice_after(iterator __pos, _Self& __x, iterator __prev) {
00413     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00414     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
00415     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__prev))
00416     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __prev))
00417     iterator __elem = __prev; ++__elem;
00418     _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl, __prev._M_iterator);
00419     if (get_allocator() == __x.get_allocator()) {
00420       _STLP_PRIV __change_ite_owner(__elem, &_M_iter_list);
00421     }
00422     else {
00423       __x._Invalidate_iterator(__elem);
00424     }
00425   }
00426 
00427   // Moves the range [__before_first + 1, __before_last + 1) to *this,
00428   //  inserting it immediately after __pos.  This is constant time.
00429   void splice_after(iterator __pos, _Self& __x,
00430                     iterator __before_first, iterator __before_last) {
00431     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
00432     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00433     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __before_last))
00434     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __before_first))
00435     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first))
00436     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_last))
00437     iterator __first = __before_first; ++__first;
00438     iterator __last = __before_last; ++__last;
00439     if (get_allocator() == __x.get_allocator()) {
00440       _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
00441     }
00442     else {
00443       __x._Invalidate_iterators(__first, __last);
00444     }
00445     _M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl,
00446                                  __before_first._M_iterator, __before_last._M_iterator);
00447   }
00448 
00449   // Linear in distance(begin(), __pos), and linear in __x.size().
00450   void splice(iterator __pos, _Self& __x) {
00451     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00452     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00453     _STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT)
00454     _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl);
00455     if (get_allocator() == __x.get_allocator()) {
00456       __x._M_iter_list._Set_owner(_M_iter_list);
00457     }
00458     else {
00459       __x._Invalidate_iterators(__x.begin(), __x.end());
00460     }
00461   }
00462 
00463   // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i).
00464   void splice(iterator __pos, _Self& __x, iterator __i) {
00465     //__pos should be owned by *this and not be the before_begin iterator
00466     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00467     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00468     //__i should be dereferenceable, not before_begin and be owned by __x
00469     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i))
00470     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list ,__i))
00471     _STLP_VERBOSE_ASSERT(!(__i == __x.before_begin()), _StlMsg_INVALID_ARGUMENT)
00472     if (get_allocator() == __x.get_allocator()) {
00473       _STLP_PRIV __change_ite_owner(__i, &_M_iter_list);
00474     }
00475     else {
00476       __x._Invalidate_iterator(__i);
00477     }
00478     _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator);
00479   }
00480 
00481   // Linear in distance(begin(), __pos), in distance(__x.begin(), __first),
00482   // and in distance(__first, __last).
00483   void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
00484     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
00485     _STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
00486     //_STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
00487     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end()))
00488     if (get_allocator() == __x.get_allocator()) {
00489       _STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
00490     }
00491     else {
00492       __x._Invalidate_iterators(__first, __last);
00493     }
00494     _M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl,
00495                            __first._M_iterator, __last._M_iterator);
00496   }
00497 
00498   void reverse()
00499   { _M_non_dbg_impl.reverse(); }
00500 
00501   void remove(const value_type& __val) {
00502     _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
00503     while (__first != __last) {
00504       _Base_iterator __next = __first;
00505       ++__next;
00506       if (__val == *__first) {
00507         _Invalidate_iterator(iterator(&_M_iter_list, __first));
00508         _M_non_dbg_impl.erase(__first);
00509       }
00510       __first = __next;
00511     }
00512   }
00513   void unique() {
00514     _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
00515     if (__first == __last) return;
00516     _Base_iterator __next = __first;
00517     while (++__next != __last) {
00518       if (*__first == *__next) {
00519         _Invalidate_iterator(iterator(&_M_iter_list, __next));
00520         _M_non_dbg_impl.erase(__next);
00521       }
00522       else
00523         __first = __next;
00524       __next = __first;
00525     }
00526   }
00527   void merge(_Self& __x) {
00528     _STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
00529 #if !defined (_STLP_NO_EXTENSIONS)
00530     /* comments below due to bug in GCC compilers: ones eat all memory  and die if see
00531      * something like namespace_name::func_name() - ptr
00532      */
00533     _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end()))
00534     _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator))
00535 #endif
00536     _M_non_dbg_impl.merge(__x._M_non_dbg_impl);
00537     if (get_allocator() == __x.get_allocator()) {
00538       __x._M_iter_list._Set_owner(_M_iter_list);
00539     }
00540     else {
00541       __x._Invalidate_iterators(__x.begin(), __x.end());
00542     }
00543   }
00544   void sort() {
00545     _M_non_dbg_impl.sort();
00546   }
00547 
00548 #if defined (_STLP_MEMBER_TEMPLATES)
00549   template <class _Predicate>
00550   void remove_if(_Predicate __pred) {
00551     _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
00552     while (__first != __last) {
00553       _Base_iterator __next = __first;
00554       ++__next;
00555       if (__pred(*__first)) {
00556         _Invalidate_iterator(iterator(&_M_iter_list, __first));
00557         _M_non_dbg_impl.erase(__first);
00558       }
00559       __first = __next;
00560     }
00561   }
00562 
00563   template <class _BinaryPredicate>
00564   void unique(_BinaryPredicate __pred) {
00565     _Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
00566     if (__first == __last) return;
00567     _Base_iterator __next = __first;
00568     while (++__next != __last) {
00569       if (__binary_pred(*__first, *__next)) {
00570         _Invalidate_iterator(iterator(&_M_iter_list, __next));
00571         _M_non_dbg_impl.erase(__next);
00572       }
00573       else
00574         __first = __next;
00575       __next = __first;
00576     }
00577   }
00578 
00579   template <class _StrictWeakOrdering>
00580   void merge(_Self& __x, _StrictWeakOrdering __ord) {
00581     _STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
00582 #if !defined (_STLP_NO_EXTENSIONS)
00583     /* comments below due to bug in GCC compilers: ones eat all memory  and die if see
00584      * something like namespace_name::func_name() - ptr
00585      */
00586     _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __ord))
00587     _STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __ord))
00588 #endif
00589     _M_non_dbg_impl.merge(__x._M_non_dbg_impl, __ord);
00590     if (get_allocator() == __x.get_allocator()) {
00591       __x._M_iter_list._Set_owner(_M_iter_list);
00592     }
00593     else {
00594       __x._Invalidate_iterators(__x.begin(), __x.end());
00595     }
00596   }
00597 
00598   template <class _StrictWeakOrdering>
00599   void sort(_StrictWeakOrdering __comp)
00600   { _M_non_dbg_impl.sort(__comp); }
00601 #endif
00602 };
00603 
00604 _STLP_END_NAMESPACE
00605 
00606 #undef _STLP_NON_DBG_SLIST
00607 
00608 #endif /* _STLP_INTERNAL_DBG_SLIST_H */
00609 
00610 // Local Variables:
00611 // mode:C++
00612 // End:



Generated on Mon Mar 10 15:32:36 2008 by  doxygen 1.5.1