libstdc++
list
Go to the documentation of this file.
00001 // Debugging list implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2015 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file debug/list
00026  *  This file is a GNU debug extension to the Standard C++ Library.
00027  */
00028 
00029 #ifndef _GLIBCXX_DEBUG_LIST
00030 #define _GLIBCXX_DEBUG_LIST 1
00031 
00032 #include <list>
00033 #include <debug/safe_sequence.h>
00034 #include <debug/safe_container.h>
00035 #include <debug/safe_iterator.h>
00036 
00037 namespace std _GLIBCXX_VISIBILITY(default)
00038 {
00039 namespace __debug
00040 {
00041   /// Class std::list with safety/checking/debug instrumentation.
00042   template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
00043     class list
00044     : public __gnu_debug::_Safe_container<
00045         list<_Tp, _Allocator>, _Allocator,
00046         __gnu_debug::_Safe_node_sequence, false>,
00047       public _GLIBCXX_STD_C::list<_Tp, _Allocator>
00048     {
00049       typedef _GLIBCXX_STD_C::list<_Tp, _Allocator>                     _Base;
00050       typedef __gnu_debug::_Safe_container<
00051         list, _Allocator, __gnu_debug::_Safe_node_sequence, false>      _Safe;
00052 
00053       typedef typename _Base::iterator          _Base_iterator;
00054       typedef typename _Base::const_iterator    _Base_const_iterator;
00055       typedef __gnu_debug::_Equal_to<_Base_const_iterator>      _Equal;
00056       typedef __gnu_debug::_Not_equal_to<_Base_const_iterator>  _Not_equal;
00057 
00058     public:
00059       typedef typename _Base::reference                 reference;
00060       typedef typename _Base::const_reference           const_reference;
00061 
00062       typedef __gnu_debug::_Safe_iterator<_Base_iterator, list>
00063                                                         iterator;
00064       typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, list>
00065                                                         const_iterator;
00066 
00067       typedef typename _Base::size_type                 size_type;
00068       typedef typename _Base::difference_type           difference_type;
00069 
00070       typedef _Tp                                       value_type;
00071       typedef _Allocator                                allocator_type;
00072       typedef typename _Base::pointer                   pointer;
00073       typedef typename _Base::const_pointer             const_pointer;
00074       typedef std::reverse_iterator<iterator>           reverse_iterator;
00075       typedef std::reverse_iterator<const_iterator>     const_reverse_iterator;
00076 
00077       // 23.2.2.1 construct/copy/destroy:
00078 
00079 #if __cplusplus < 201103L
00080       list()
00081       : _Base() { }
00082 
00083       list(const list& __x)
00084       : _Base(__x) { }
00085 
00086       ~list() { }
00087 #else
00088       list() = default;
00089       list(const list&) = default;
00090       list(list&&) = default;
00091 
00092       list(initializer_list<value_type> __l,
00093            const allocator_type& __a = allocator_type())
00094       : _Base(__l, __a) { }
00095 
00096       ~list() = default;
00097 #endif
00098 
00099       explicit
00100       list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
00101       : _Base(__a) { }
00102 
00103 #if __cplusplus >= 201103L
00104       explicit
00105       list(size_type __n)
00106       : _Base(__n) { }
00107 
00108       list(size_type __n, const _Tp& __value,
00109            const _Allocator& __a = _Allocator())
00110       : _Base(__n, __value, __a) { }
00111 #else
00112       explicit
00113       list(size_type __n, const _Tp& __value = _Tp(),
00114            const _Allocator& __a = _Allocator())
00115       : _Base(__n, __value, __a) { }
00116 #endif
00117 
00118 #if __cplusplus >= 201103L
00119       template<class _InputIterator,
00120                typename = std::_RequireInputIter<_InputIterator>>
00121 #else
00122       template<class _InputIterator>
00123 #endif
00124         list(_InputIterator __first, _InputIterator __last,
00125              const _Allocator& __a = _Allocator())
00126         : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
00127                                                                      __last)),
00128                 __gnu_debug::__base(__last), __a)
00129         { }
00130 
00131       list(const _Base& __x)
00132       : _Base(__x) { }
00133 
00134 #if __cplusplus < 201103L
00135       list&
00136       operator=(const list& __x)
00137       {
00138         this->_M_safe() = __x;
00139         _M_base() = __x;
00140         return *this;
00141       }
00142 #else
00143       list&
00144       operator=(const list&) = default;
00145 
00146       list&
00147       operator=(list&&) = default;
00148 
00149       list&
00150       operator=(initializer_list<value_type> __l)
00151       {
00152         this->_M_invalidate_all();
00153         _M_base() = __l;
00154         return *this;
00155       }
00156 
00157       void
00158       assign(initializer_list<value_type> __l)
00159       {
00160         _Base::assign(__l);
00161         this->_M_invalidate_all();
00162       }
00163 #endif
00164 
00165 #if __cplusplus >= 201103L
00166       template<class _InputIterator,
00167                typename = std::_RequireInputIter<_InputIterator>>
00168 #else
00169       template<class _InputIterator>
00170 #endif
00171         void
00172         assign(_InputIterator __first, _InputIterator __last)
00173         {
00174           __glibcxx_check_valid_range(__first, __last);
00175           _Base::assign(__gnu_debug::__base(__first),
00176                         __gnu_debug::__base(__last));
00177           this->_M_invalidate_all();
00178         }
00179 
00180       void
00181       assign(size_type __n, const _Tp& __t)
00182       {
00183         _Base::assign(__n, __t);
00184         this->_M_invalidate_all();
00185       }
00186 
00187       using _Base::get_allocator;
00188 
00189       // iterators:
00190       iterator
00191       begin() _GLIBCXX_NOEXCEPT
00192       { return iterator(_Base::begin(), this); }
00193 
00194       const_iterator
00195       begin() const _GLIBCXX_NOEXCEPT
00196       { return const_iterator(_Base::begin(), this); }
00197 
00198       iterator
00199       end() _GLIBCXX_NOEXCEPT
00200       { return iterator(_Base::end(), this); }
00201 
00202       const_iterator
00203       end() const _GLIBCXX_NOEXCEPT
00204       { return const_iterator(_Base::end(), this); }
00205 
00206       reverse_iterator
00207       rbegin() _GLIBCXX_NOEXCEPT
00208       { return reverse_iterator(end()); }
00209 
00210       const_reverse_iterator
00211       rbegin() const _GLIBCXX_NOEXCEPT
00212       { return const_reverse_iterator(end()); }
00213 
00214       reverse_iterator
00215       rend() _GLIBCXX_NOEXCEPT
00216       { return reverse_iterator(begin()); }
00217 
00218       const_reverse_iterator
00219       rend() const _GLIBCXX_NOEXCEPT
00220       { return const_reverse_iterator(begin()); }
00221 
00222 #if __cplusplus >= 201103L
00223       const_iterator
00224       cbegin() const noexcept
00225       { return const_iterator(_Base::begin(), this); }
00226 
00227       const_iterator
00228       cend() const noexcept
00229       { return const_iterator(_Base::end(), this); }
00230 
00231       const_reverse_iterator
00232       crbegin() const noexcept
00233       { return const_reverse_iterator(end()); }
00234 
00235       const_reverse_iterator
00236       crend() const noexcept
00237       { return const_reverse_iterator(begin()); }
00238 #endif
00239 
00240       // 23.2.2.2 capacity:
00241       using _Base::empty;
00242       using _Base::size;
00243       using _Base::max_size;
00244 
00245 #if __cplusplus >= 201103L
00246       void
00247       resize(size_type __sz)
00248       {
00249         this->_M_detach_singular();
00250 
00251         // if __sz < size(), invalidate all iterators in [begin + __sz, end())
00252         _Base_iterator __victim = _Base::begin();
00253         _Base_iterator __end = _Base::end();
00254         for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
00255           ++__victim;
00256 
00257         for (; __victim != __end; ++__victim)
00258           this->_M_invalidate_if(_Equal(__victim));
00259 
00260         __try
00261           {
00262             _Base::resize(__sz);
00263           }
00264         __catch(...)
00265           {
00266             this->_M_revalidate_singular();
00267             __throw_exception_again;
00268           }
00269       }
00270 
00271       void
00272       resize(size_type __sz, const _Tp& __c)
00273       {
00274         this->_M_detach_singular();
00275 
00276         // if __sz < size(), invalidate all iterators in [begin + __sz, end())
00277         _Base_iterator __victim = _Base::begin();
00278         _Base_iterator __end = _Base::end();
00279         for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
00280           ++__victim;
00281 
00282         for (; __victim != __end; ++__victim)
00283           this->_M_invalidate_if(_Equal(__victim));
00284 
00285         __try
00286           {
00287             _Base::resize(__sz, __c);
00288           }
00289         __catch(...)
00290           {
00291             this->_M_revalidate_singular();
00292             __throw_exception_again;
00293           }
00294       }
00295 #else
00296       void
00297       resize(size_type __sz, _Tp __c = _Tp())
00298       {
00299         this->_M_detach_singular();
00300 
00301         // if __sz < size(), invalidate all iterators in [begin + __sz, end())
00302         _Base_iterator __victim = _Base::begin();
00303         _Base_iterator __end = _Base::end();
00304         for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
00305           ++__victim;
00306 
00307         for (; __victim != __end; ++__victim)
00308           this->_M_invalidate_if(_Equal(__victim));
00309 
00310         __try
00311           {
00312             _Base::resize(__sz, __c);
00313           }
00314         __catch(...)
00315           {
00316             this->_M_revalidate_singular();
00317             __throw_exception_again;
00318           }
00319       }
00320 #endif
00321 
00322       // element access:
00323       reference
00324       front() _GLIBCXX_NOEXCEPT
00325       {
00326         __glibcxx_check_nonempty();
00327         return _Base::front();
00328       }
00329 
00330       const_reference
00331       front() const _GLIBCXX_NOEXCEPT
00332       {
00333         __glibcxx_check_nonempty();
00334         return _Base::front();
00335       }
00336 
00337       reference
00338       back() _GLIBCXX_NOEXCEPT
00339       {
00340         __glibcxx_check_nonempty();
00341         return _Base::back();
00342       }
00343 
00344       const_reference
00345       back() const _GLIBCXX_NOEXCEPT
00346       {
00347         __glibcxx_check_nonempty();
00348         return _Base::back();
00349       }
00350 
00351       // 23.2.2.3 modifiers:
00352       using _Base::push_front;
00353 
00354 #if __cplusplus >= 201103L
00355       using _Base::emplace_front;
00356 #endif
00357 
00358       void
00359       pop_front() _GLIBCXX_NOEXCEPT
00360       {
00361         __glibcxx_check_nonempty();
00362         this->_M_invalidate_if(_Equal(_Base::begin()));
00363         _Base::pop_front();
00364       }
00365 
00366       using _Base::push_back;
00367 
00368 #if __cplusplus >= 201103L
00369       using _Base::emplace_back;
00370 #endif
00371 
00372       void
00373       pop_back() _GLIBCXX_NOEXCEPT
00374       {
00375         __glibcxx_check_nonempty();
00376         this->_M_invalidate_if(_Equal(--_Base::end()));
00377         _Base::pop_back();
00378       }
00379 
00380 #if __cplusplus >= 201103L
00381       template<typename... _Args>
00382         iterator
00383         emplace(const_iterator __position, _Args&&... __args)
00384         {
00385           __glibcxx_check_insert(__position);
00386           return iterator(_Base::emplace(__position.base(),
00387                                         std::forward<_Args>(__args)...), this);
00388         }
00389 #endif
00390 
00391      iterator
00392 #if __cplusplus >= 201103L
00393      insert(const_iterator __position, const _Tp& __x)
00394 #else
00395      insert(iterator __position, const _Tp& __x)
00396 #endif
00397      {
00398        __glibcxx_check_insert(__position);
00399        return iterator(_Base::insert(__position.base(), __x), this);
00400      }
00401 
00402 #if __cplusplus >= 201103L
00403       iterator
00404       insert(const_iterator __position, _Tp&& __x)
00405       { return emplace(__position, std::move(__x)); }
00406 
00407       iterator
00408       insert(const_iterator __p, initializer_list<value_type> __l)
00409       {
00410         __glibcxx_check_insert(__p);
00411         return iterator(_Base::insert(__p.base(), __l), this);
00412       }
00413 #endif
00414 
00415 #if __cplusplus >= 201103L
00416       iterator
00417       insert(const_iterator __position, size_type __n, const _Tp& __x)
00418       {
00419         __glibcxx_check_insert(__position);
00420         return iterator(_Base::insert(__position.base(), __n, __x), this);
00421       }
00422 #else
00423       void
00424       insert(iterator __position, size_type __n, const _Tp& __x)
00425       {
00426         __glibcxx_check_insert(__position);
00427         _Base::insert(__position.base(), __n, __x);
00428       }
00429 #endif
00430 
00431 #if __cplusplus >= 201103L
00432       template<class _InputIterator,
00433                typename = std::_RequireInputIter<_InputIterator>>
00434         iterator
00435         insert(const_iterator __position, _InputIterator __first,
00436                _InputIterator __last)
00437         {
00438           __glibcxx_check_insert_range(__position, __first, __last);
00439           return iterator(_Base::insert(__position.base(),
00440                                         __gnu_debug::__base(__first),
00441                                         __gnu_debug::__base(__last)),
00442                           this);
00443         }
00444 #else
00445       template<class _InputIterator>
00446         void
00447         insert(iterator __position, _InputIterator __first,
00448                _InputIterator __last)
00449         {
00450           __glibcxx_check_insert_range(__position, __first, __last);
00451           _Base::insert(__position.base(), __gnu_debug::__base(__first),
00452                                            __gnu_debug::__base(__last));
00453         }
00454 #endif
00455 
00456     private:
00457       _Base_iterator
00458 #if __cplusplus >= 201103L
00459       _M_erase(_Base_const_iterator __position) noexcept
00460 #else
00461       _M_erase(_Base_iterator __position)
00462 #endif
00463       {
00464         this->_M_invalidate_if(_Equal(__position));
00465         return _Base::erase(__position);
00466       }
00467 
00468     public:
00469       iterator
00470 #if __cplusplus >= 201103L
00471       erase(const_iterator __position) noexcept
00472 #else
00473       erase(iterator __position)
00474 #endif
00475       {
00476         __glibcxx_check_erase(__position);
00477         return iterator(_M_erase(__position.base()), this);
00478       }
00479 
00480       iterator
00481 #if __cplusplus >= 201103L
00482       erase(const_iterator __first, const_iterator __last) noexcept
00483 #else
00484       erase(iterator __first, iterator __last)
00485 #endif
00486       {
00487         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00488         // 151. can't currently clear() empty container
00489         __glibcxx_check_erase_range(__first, __last);
00490         for (_Base_const_iterator __victim = __first.base();
00491              __victim != __last.base(); ++__victim)
00492           {
00493             _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
00494                                   _M_message(__gnu_debug::__msg_valid_range)
00495                                   ._M_iterator(__first, "position")
00496                                   ._M_iterator(__last, "last"));
00497             this->_M_invalidate_if(_Equal(__victim));
00498           }
00499         return iterator(_Base::erase(__first.base(), __last.base()), this);
00500       }
00501 
00502       void
00503       swap(list& __x)
00504 #if __cplusplus >= 201103L
00505         noexcept( noexcept(declval<_Base>().swap(__x)) )
00506 #endif
00507       {
00508         _Safe::_M_swap(__x);
00509         _Base::swap(__x);
00510       }
00511 
00512       void
00513       clear() _GLIBCXX_NOEXCEPT
00514       {
00515         _Base::clear();
00516         this->_M_invalidate_all();
00517       }
00518 
00519       // 23.2.2.4 list operations:
00520       void
00521 #if __cplusplus >= 201103L
00522       splice(const_iterator __position, list&& __x) noexcept
00523 #else
00524       splice(iterator __position, list& __x)
00525 #endif
00526       {
00527         _GLIBCXX_DEBUG_VERIFY(&__x != this,
00528                               _M_message(__gnu_debug::__msg_self_splice)
00529                               ._M_sequence(*this, "this"));
00530         this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
00531         _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()));
00532       }
00533 
00534 #if __cplusplus >= 201103L
00535       void
00536       splice(const_iterator __position, list& __x) noexcept
00537       { splice(__position, std::move(__x)); }
00538 #endif
00539 
00540       void
00541 #if __cplusplus >= 201103L
00542       splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
00543 #else
00544       splice(iterator __position, list& __x, iterator __i)
00545 #endif
00546       {
00547         __glibcxx_check_insert(__position);
00548 
00549         // We used to perform the splice_alloc check:  not anymore, redundant
00550         // after implementing the relevant bits of N1599.
00551 
00552         _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(),
00553                               _M_message(__gnu_debug::__msg_splice_bad)
00554                               ._M_iterator(__i, "__i"));
00555         _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(&__x),
00556                               _M_message(__gnu_debug::__msg_splice_other)
00557                              ._M_iterator(__i, "__i")._M_sequence(__x, "__x"));
00558 
00559         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00560         // 250. splicing invalidates iterators
00561         this->_M_transfer_from_if(__x, _Equal(__i.base()));
00562         _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
00563                       __i.base());
00564       }
00565 
00566 #if __cplusplus >= 201103L
00567       void
00568       splice(const_iterator __position, list& __x, const_iterator __i) noexcept
00569       { splice(__position, std::move(__x), __i); }
00570 #endif
00571 
00572       void
00573 #if __cplusplus >= 201103L
00574       splice(const_iterator __position, list&& __x, const_iterator __first,
00575              const_iterator __last) noexcept
00576 #else
00577       splice(iterator __position, list& __x, iterator __first,
00578              iterator __last)
00579 #endif
00580       {
00581         __glibcxx_check_insert(__position);
00582         __glibcxx_check_valid_range(__first, __last);
00583         _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(&__x),
00584                               _M_message(__gnu_debug::__msg_splice_other)
00585                               ._M_sequence(__x, "x")
00586                               ._M_iterator(__first, "first"));
00587 
00588         // We used to perform the splice_alloc check:  not anymore, redundant
00589         // after implementing the relevant bits of N1599.
00590 
00591         for (_Base_const_iterator __tmp = __first.base();
00592              __tmp != __last.base(); ++__tmp)
00593           {
00594             _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
00595                                   _M_message(__gnu_debug::__msg_valid_range)
00596                                   ._M_iterator(__first, "first")
00597                                   ._M_iterator(__last, "last"));
00598             _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position.base(),
00599                                 _M_message(__gnu_debug::__msg_splice_overlap)
00600                                   ._M_iterator(__tmp, "position")
00601                                   ._M_iterator(__first, "first")
00602                                   ._M_iterator(__last, "last"));
00603             // _GLIBCXX_RESOLVE_LIB_DEFECTS
00604             // 250. splicing invalidates iterators
00605             this->_M_transfer_from_if(__x, _Equal(__tmp));
00606           }
00607 
00608         _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
00609                       __first.base(), __last.base());
00610       }
00611 
00612 #if __cplusplus >= 201103L
00613       void
00614       splice(const_iterator __position, list& __x,
00615              const_iterator __first, const_iterator __last) noexcept
00616       { splice(__position, std::move(__x), __first, __last); }
00617 #endif
00618 
00619       void
00620       remove(const _Tp& __value)
00621       {
00622         for (_Base_iterator __x = _Base::begin(); __x != _Base::end(); )
00623           {
00624             if (*__x == __value)
00625               __x = _M_erase(__x);
00626             else
00627               ++__x;
00628           }
00629       }
00630 
00631       template<class _Predicate>
00632         void
00633         remove_if(_Predicate __pred)
00634         {
00635           for (_Base_iterator __x = _Base::begin(); __x != _Base::end(); )
00636             {
00637               if (__pred(*__x))
00638                 __x = _M_erase(__x);
00639               else
00640                 ++__x;
00641             }
00642         }
00643 
00644       void
00645       unique()
00646       {
00647         _Base_iterator __first = _Base::begin();
00648         _Base_iterator __last = _Base::end();
00649         if (__first == __last)
00650           return;
00651         _Base_iterator __next = __first; ++__next;
00652         while (__next != __last)
00653           {
00654             if (*__first == *__next)
00655               __next = _M_erase(__next);
00656             else
00657               __first = __next++;
00658           }
00659       }
00660 
00661       template<class _BinaryPredicate>
00662         void
00663         unique(_BinaryPredicate __binary_pred)
00664         {
00665           _Base_iterator __first = _Base::begin();
00666           _Base_iterator __last = _Base::end();
00667           if (__first == __last)
00668             return;
00669           _Base_iterator __next = __first; ++__next;
00670           while (__next != __last)
00671             {
00672               if (__binary_pred(*__first, *__next))
00673                 __next = _M_erase(__next);
00674               else
00675                 __first = __next++;
00676             }
00677         }
00678 
00679       void
00680 #if __cplusplus >= 201103L
00681       merge(list&& __x)
00682 #else
00683       merge(list& __x)
00684 #endif
00685       {
00686         // _GLIBCXX_RESOLVE_LIB_DEFECTS
00687         // 300. list::merge() specification incomplete
00688         if (this != &__x)
00689           {
00690             __glibcxx_check_sorted(_Base::begin(), _Base::end());
00691             __glibcxx_check_sorted(__x.begin().base(), __x.end().base());
00692             this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
00693             _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
00694           }
00695       }
00696 
00697 #if __cplusplus >= 201103L
00698       void
00699       merge(list& __x)
00700       { merge(std::move(__x)); }
00701 #endif
00702 
00703       template<class _Compare>
00704         void
00705 #if __cplusplus >= 201103L
00706         merge(list&& __x, _Compare __comp)
00707 #else
00708         merge(list& __x, _Compare __comp)
00709 #endif
00710         {
00711           // _GLIBCXX_RESOLVE_LIB_DEFECTS
00712           // 300. list::merge() specification incomplete
00713           if (this != &__x)
00714             {
00715               __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(),
00716                                           __comp);
00717               __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(),
00718                                           __comp);
00719               this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
00720               _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
00721             }
00722         }
00723 
00724 #if __cplusplus >= 201103L
00725       template<typename _Compare>
00726         void
00727         merge(list& __x, _Compare __comp)
00728         { merge(std::move(__x), __comp); }
00729 #endif
00730 
00731       void
00732       sort() { _Base::sort(); }
00733 
00734       template<typename _StrictWeakOrdering>
00735         void
00736         sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
00737 
00738       using _Base::reverse;
00739 
00740       _Base&
00741       _M_base() _GLIBCXX_NOEXCEPT       { return *this; }
00742 
00743       const _Base&
00744       _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
00745     };
00746 
00747   template<typename _Tp, typename _Alloc>
00748     inline bool
00749     operator==(const list<_Tp, _Alloc>& __lhs,
00750                const list<_Tp, _Alloc>& __rhs)
00751     { return __lhs._M_base() == __rhs._M_base(); }
00752 
00753   template<typename _Tp, typename _Alloc>
00754     inline bool
00755     operator!=(const list<_Tp, _Alloc>& __lhs,
00756                const list<_Tp, _Alloc>& __rhs)
00757     { return __lhs._M_base() != __rhs._M_base(); }
00758 
00759   template<typename _Tp, typename _Alloc>
00760     inline bool
00761     operator<(const list<_Tp, _Alloc>& __lhs,
00762               const list<_Tp, _Alloc>& __rhs)
00763     { return __lhs._M_base() < __rhs._M_base(); }
00764 
00765   template<typename _Tp, typename _Alloc>
00766     inline bool
00767     operator<=(const list<_Tp, _Alloc>& __lhs,
00768                const list<_Tp, _Alloc>& __rhs)
00769     { return __lhs._M_base() <= __rhs._M_base(); }
00770 
00771   template<typename _Tp, typename _Alloc>
00772     inline bool
00773     operator>=(const list<_Tp, _Alloc>& __lhs,
00774                const list<_Tp, _Alloc>& __rhs)
00775     { return __lhs._M_base() >= __rhs._M_base(); }
00776 
00777   template<typename _Tp, typename _Alloc>
00778     inline bool
00779     operator>(const list<_Tp, _Alloc>& __lhs,
00780               const list<_Tp, _Alloc>& __rhs)
00781     { return __lhs._M_base() > __rhs._M_base(); }
00782 
00783   template<typename _Tp, typename _Alloc>
00784     inline void
00785     swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
00786     { __lhs.swap(__rhs); }
00787 
00788 } // namespace __debug
00789 } // namespace std
00790 
00791 #ifndef _GLIBCXX_DEBUG_PEDANTIC
00792 namespace __gnu_debug
00793 {
00794   template<class _Tp, class _Alloc>
00795     struct _Insert_range_from_self_is_safe<std::__debug::list<_Tp, _Alloc> >
00796     { enum { __value = 1 }; };
00797 }
00798 #endif
00799 
00800 #endif