libstdc++
|
00001 // <forward_list> -*- C++ -*- 00002 00003 // Copyright (C) 2010 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/forward_list 00026 * This file is a GNU debug extension to the Standard C++ Library. 00027 */ 00028 00029 #ifndef _GLIBCXX_DEBUG_FORWARD_LIST 00030 #define _GLIBCXX_DEBUG_FORWARD_LIST 1 00031 00032 #pragma GCC system_header 00033 00034 #include <forward_list> 00035 #include <debug/safe_sequence.h> 00036 #include <debug/safe_iterator.h> 00037 00038 namespace std _GLIBCXX_VISIBILITY(default) 00039 { 00040 namespace __debug 00041 { 00042 /// Class std::forward_list with safety/checking/debug instrumentation. 00043 template<typename _Tp, typename _Alloc = std::allocator<_Tp> > 00044 class forward_list 00045 : public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc>, 00046 public __gnu_debug::_Safe_sequence<forward_list<_Tp, _Alloc> > 00047 { 00048 typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base; 00049 00050 typedef typename _Base::iterator _Base_iterator; 00051 typedef typename _Base::const_iterator _Base_const_iterator; 00052 public: 00053 typedef typename _Base::reference reference; 00054 typedef typename _Base::const_reference const_reference; 00055 00056 typedef __gnu_debug::_Safe_iterator<_Base_iterator, 00057 forward_list> iterator; 00058 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, 00059 forward_list> const_iterator; 00060 00061 typedef typename _Base::size_type size_type; 00062 typedef typename _Base::difference_type difference_type; 00063 00064 typedef _Tp value_type; 00065 typedef _Alloc allocator_type; 00066 typedef typename _Base::pointer pointer; 00067 typedef typename _Base::const_pointer const_pointer; 00068 00069 // 23.2.3.1 construct/copy/destroy: 00070 explicit 00071 forward_list(const _Alloc& __al = _Alloc()) 00072 : _Base(__al) { } 00073 00074 forward_list(const forward_list& __list, const _Alloc& __al) 00075 : _Base(__list, __al) 00076 { } 00077 00078 forward_list(forward_list&& __list, const _Alloc& __al) 00079 : _Base(std::move(__list._M_base()), __al) 00080 { 00081 this->_M_swap(__list); 00082 } 00083 00084 explicit 00085 forward_list(size_type __n) 00086 : _Base(__n) 00087 { } 00088 00089 forward_list(size_type __n, const _Tp& __value, 00090 const _Alloc& __al = _Alloc()) 00091 : _Base(__n, __value, __al) 00092 { } 00093 00094 template<typename _InputIterator> 00095 forward_list(_InputIterator __first, _InputIterator __last, 00096 const _Alloc& __al = _Alloc()) 00097 : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first, 00098 __last)), 00099 __gnu_debug::__base(__last), __al) 00100 { } 00101 00102 forward_list(const forward_list& __list) 00103 : _Base(__list) 00104 { } 00105 00106 forward_list(forward_list&& __list) noexcept 00107 : _Base(std::move(__list._M_base())) 00108 { 00109 this->_M_swap(__list); 00110 } 00111 00112 forward_list(std::initializer_list<_Tp> __il, 00113 const _Alloc& __al = _Alloc()) 00114 : _Base(__il, __al) 00115 { } 00116 00117 ~forward_list() noexcept 00118 { } 00119 00120 forward_list& 00121 operator=(const forward_list& __list) 00122 { 00123 static_cast<_Base&>(*this) = __list; 00124 this->_M_invalidate_all(); 00125 return *this; 00126 } 00127 00128 forward_list& 00129 operator=(forward_list&& __list) 00130 { 00131 // NB: DR 1204. 00132 // NB: DR 675. 00133 clear(); 00134 swap(__list); 00135 return *this; 00136 } 00137 00138 forward_list& 00139 operator=(std::initializer_list<_Tp> __il) 00140 { 00141 static_cast<_Base&>(*this) = __il; 00142 this->_M_invalidate_all(); 00143 return *this; 00144 } 00145 00146 template<typename _InputIterator> 00147 void 00148 assign(_InputIterator __first, _InputIterator __last) 00149 { 00150 __glibcxx_check_valid_range(__first, __last); 00151 _Base::assign(__gnu_debug::__base(__first), 00152 __gnu_debug::__base(__last)); 00153 this->_M_invalidate_all(); 00154 } 00155 00156 void 00157 assign(size_type __n, const _Tp& __val) 00158 { 00159 _Base::assign(__n, __val); 00160 this->_M_invalidate_all(); 00161 } 00162 00163 void 00164 assign(std::initializer_list<_Tp> __il) 00165 { 00166 _Base::assign(__il); 00167 this->_M_invalidate_all(); 00168 } 00169 00170 using _Base::get_allocator; 00171 00172 // iterators: 00173 00174 iterator 00175 before_begin() noexcept 00176 { return iterator(_Base::before_begin(), this); } 00177 00178 const_iterator 00179 before_begin() const noexcept 00180 { return const_iterator(_Base::before_begin(), this); } 00181 00182 iterator 00183 begin() noexcept 00184 { return iterator(_Base::begin(), this); } 00185 00186 const_iterator 00187 begin() const noexcept 00188 { return const_iterator(_Base::begin(), this); } 00189 00190 iterator 00191 end() noexcept 00192 { return iterator(_Base::end(), this); } 00193 00194 const_iterator 00195 end() const noexcept 00196 { return const_iterator(_Base::end(), this); } 00197 00198 const_iterator 00199 cbegin() const noexcept 00200 { return const_iterator(_Base::cbegin(), this); } 00201 00202 const_iterator 00203 cbefore_begin() const noexcept 00204 { return const_iterator(_Base::cbefore_begin(), this); } 00205 00206 const_iterator 00207 cend() const noexcept 00208 { return const_iterator(_Base::cend(), this); } 00209 00210 using _Base::empty; 00211 using _Base::max_size; 00212 00213 // element access: 00214 00215 reference 00216 front() 00217 { 00218 __glibcxx_check_nonempty(); 00219 return _Base::front(); 00220 } 00221 00222 const_reference 00223 front() const 00224 { 00225 __glibcxx_check_nonempty(); 00226 return _Base::front(); 00227 } 00228 00229 // modiļ¬ers: 00230 00231 using _Base::emplace_front; 00232 using _Base::push_front; 00233 00234 void 00235 pop_front() 00236 { 00237 __glibcxx_check_nonempty(); 00238 this->_M_invalidate_if([this](_Base_const_iterator __it) 00239 { return __it == this->_M_base().cbegin(); }); 00240 _Base::pop_front(); 00241 } 00242 00243 template<typename... _Args> 00244 iterator 00245 emplace_after(const_iterator __pos, _Args&&... __args) 00246 { 00247 __glibcxx_check_insert_after(__pos); 00248 return iterator(_Base::emplace_after(__pos.base(), 00249 std::forward<_Args>(__args)...), 00250 this); 00251 } 00252 00253 iterator 00254 insert_after(const_iterator __pos, const _Tp& __val) 00255 { 00256 __glibcxx_check_insert_after(__pos); 00257 return iterator(_Base::insert_after(__pos.base(), __val), this); 00258 } 00259 00260 iterator 00261 insert_after(const_iterator __pos, _Tp&& __val) 00262 { 00263 __glibcxx_check_insert_after(__pos); 00264 return iterator(_Base::insert_after(__pos.base(), std::move(__val)), 00265 this); 00266 } 00267 00268 iterator 00269 insert_after(const_iterator __pos, size_type __n, const _Tp& __val) 00270 { 00271 __glibcxx_check_insert_after(__pos); 00272 return iterator(_Base::insert_after(__pos.base(), __n, __val), 00273 this); 00274 } 00275 00276 template<typename _InputIterator> 00277 iterator 00278 insert_after(const_iterator __pos, 00279 _InputIterator __first, _InputIterator __last) 00280 { 00281 __glibcxx_check_insert_range_after(__pos, __first, __last); 00282 return iterator(_Base::insert_after(__pos.base(), 00283 __gnu_debug::__base(__first), 00284 __gnu_debug::__base(__last)), 00285 this); 00286 } 00287 00288 iterator 00289 insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) 00290 { 00291 __glibcxx_check_insert_after(__pos); 00292 return iterator(_Base::insert_after(__pos.base(), __il), this); 00293 } 00294 00295 private: 00296 _Base_iterator 00297 _M_erase_after(_Base_const_iterator __pos) 00298 { 00299 _Base_const_iterator __next = std::next(__pos); 00300 this->_M_invalidate_if([__next](_Base_const_iterator __it) 00301 { return __it == __next; }); 00302 return _Base::erase_after(__pos); 00303 } 00304 public: 00305 iterator 00306 erase_after(const_iterator __pos) 00307 { 00308 __glibcxx_check_erase_after(__pos); 00309 return iterator(_M_erase_after(__pos.base()), this); 00310 } 00311 00312 iterator 00313 erase_after(const_iterator __pos, const_iterator __last) 00314 { 00315 __glibcxx_check_erase_range_after(__pos, __last); 00316 for (_Base_const_iterator __victim = std::next(__pos.base()); 00317 __victim != __last.base(); ++__victim) 00318 { 00319 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), 00320 _M_message(__gnu_debug::__msg_valid_range2) 00321 ._M_sequence(*this, "this") 00322 ._M_iterator(__pos, "pos") 00323 ._M_iterator(__last, "last")); 00324 this->_M_invalidate_if([__victim](_Base_const_iterator __it) 00325 { return __it == __victim; }); 00326 } 00327 return iterator(_Base::erase_after(__pos.base(), __last.base()), this); 00328 } 00329 00330 void 00331 swap(forward_list& __list) 00332 { 00333 _Base::swap(__list); 00334 this->_M_swap(__list); 00335 } 00336 00337 void 00338 resize(size_type __sz) 00339 { 00340 this->_M_detach_singular(); 00341 00342 // if __sz < size(), invalidate all iterators in [begin+__sz, end() 00343 _Base_iterator __victim = _Base::begin(); 00344 _Base_iterator __end = _Base::end(); 00345 for (size_type __i = __sz; __victim != __end && __i > 0; --__i) 00346 ++__victim; 00347 00348 for (; __victim != __end; ++__victim) 00349 { 00350 this->_M_invalidate_if([__victim](_Base_const_iterator __it) 00351 { return __it == __victim; }); 00352 } 00353 00354 __try 00355 { 00356 _Base::resize(__sz); 00357 } 00358 __catch(...) 00359 { 00360 this->_M_revalidate_singular(); 00361 __throw_exception_again; 00362 } 00363 } 00364 00365 void 00366 resize(size_type __sz, const value_type& __val) 00367 { 00368 this->_M_detach_singular(); 00369 00370 // if __sz < size(), invalidate all iterators in [begin+__sz, end()) 00371 _Base_iterator __victim = _Base::begin(); 00372 _Base_iterator __end = _Base::end(); 00373 for (size_type __i = __sz; __victim != __end && __i > 0; --__i) 00374 ++__victim; 00375 00376 for (; __victim != __end; ++__victim) 00377 { 00378 this->_M_invalidate_if([__victim](_Base_const_iterator __it) 00379 { return __it == __victim; }); 00380 } 00381 00382 __try 00383 { 00384 _Base::resize(__sz, __val); 00385 } 00386 __catch(...) 00387 { 00388 this->_M_revalidate_singular(); 00389 __throw_exception_again; 00390 } 00391 } 00392 00393 void 00394 clear() noexcept 00395 { 00396 _Base::clear(); 00397 this->_M_invalidate_all(); 00398 } 00399 00400 // 23.2.3.5 forward_list operations: 00401 void 00402 splice_after(const_iterator __pos, forward_list&& __list) 00403 { 00404 __glibcxx_check_insert_after(__pos); 00405 _GLIBCXX_DEBUG_VERIFY(&__list != this, 00406 _M_message(__gnu_debug::__msg_self_splice) 00407 ._M_sequence(*this, "this")); 00408 this->_M_transfer_from_if(__list, [&__list](_Base_const_iterator __it) 00409 { 00410 return __it != __list._M_base().cbefore_begin() 00411 && __it != __list._M_base().end(); 00412 }); 00413 _Base::splice_after(__pos.base(), std::move(__list._M_base())); 00414 } 00415 00416 void 00417 splice_after(const_iterator __pos, forward_list&& __list, 00418 const_iterator __i) 00419 { 00420 __glibcxx_check_insert_after(__pos); 00421 _GLIBCXX_DEBUG_VERIFY(__i._M_before_dereferenceable(), 00422 _M_message(__gnu_debug::__msg_splice_bad) 00423 ._M_iterator(__i, "__i")); 00424 _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(&__list), 00425 _M_message(__gnu_debug::__msg_splice_other) 00426 ._M_iterator(__i, "__i") 00427 ._M_sequence(__list, "__list")); 00428 00429 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00430 // 250. splicing invalidates iterators 00431 _Base_const_iterator __next = std::next(__i.base()); 00432 this->_M_transfer_from_if(__list, [__next](_Base_const_iterator __it) 00433 { return __it == __next; }); 00434 _Base::splice_after(__pos.base(), std::move(__list._M_base()), 00435 __i.base()); 00436 } 00437 00438 void 00439 splice_after(const_iterator __pos, forward_list&& __list, 00440 const_iterator __before, const_iterator __last) 00441 { 00442 __glibcxx_check_insert_after(__pos); 00443 __glibcxx_check_valid_range(__before, __last); 00444 _GLIBCXX_DEBUG_VERIFY(__before._M_attached_to(&__list), 00445 _M_message(__gnu_debug::__msg_splice_other) 00446 ._M_sequence(__list, "list") 00447 ._M_iterator(__before, "before")); 00448 _GLIBCXX_DEBUG_VERIFY(__before._M_dereferenceable() 00449 || __before._M_is_before_begin(), 00450 _M_message(__gnu_debug::__msg_valid_range2) 00451 ._M_sequence(__list, "list") 00452 ._M_iterator(__before, "before") 00453 ._M_iterator(__last, "last")); 00454 _GLIBCXX_DEBUG_VERIFY(__before != __last, 00455 _M_message(__gnu_debug::__msg_valid_range2) 00456 ._M_sequence(__list, "list") 00457 ._M_iterator(__before, "before") 00458 ._M_iterator(__last, "last")); 00459 00460 for (_Base_const_iterator __tmp = std::next(__before.base()); 00461 __tmp != __last.base(); ++__tmp) 00462 { 00463 _GLIBCXX_DEBUG_VERIFY(__tmp != __list._M_base().end(), 00464 _M_message(__gnu_debug::__msg_valid_range2) 00465 ._M_sequence(__list, "list") 00466 ._M_iterator(__before, "before") 00467 ._M_iterator(__last, "last")); 00468 _GLIBCXX_DEBUG_VERIFY(&__list != this || __tmp != __pos.base(), 00469 _M_message(__gnu_debug::__msg_splice_overlap) 00470 ._M_iterator(__tmp, "position") 00471 ._M_iterator(__before, "before") 00472 ._M_iterator(__last, "last")); 00473 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00474 // 250. splicing invalidates iterators 00475 this->_M_transfer_from_if(__list, [__tmp](_Base_const_iterator __it) 00476 { return __it == __tmp; }); 00477 } 00478 00479 _Base::splice_after(__pos.base(), std::move(__list._M_base()), 00480 __before.base(), __last.base()); 00481 } 00482 00483 void 00484 remove(const _Tp& __val) 00485 { 00486 _Base_iterator __x = _Base::before_begin(); 00487 _Base_iterator __old = __x++; 00488 while (__x != _Base::end()) 00489 { 00490 if (*__x == __val) 00491 __x = _M_erase_after(__old); 00492 else 00493 __old = __x++; 00494 } 00495 } 00496 00497 template<typename _Pred> 00498 void 00499 remove_if(_Pred __pred) 00500 { 00501 _Base_iterator __x = _Base::before_begin(); 00502 _Base_iterator __old = __x++; 00503 while (__x != _Base::end()) 00504 { 00505 if (__pred(*__x)) 00506 __x = _M_erase_after(__old); 00507 else 00508 __old = __x++; 00509 } 00510 } 00511 00512 void 00513 unique() 00514 { 00515 _Base_iterator __first = _Base::begin(); 00516 _Base_iterator __last = _Base::end(); 00517 if (__first == __last) 00518 return; 00519 _Base_iterator __next = std::next(__first); 00520 while (__next != __last) 00521 { 00522 if (*__first == *__next) 00523 __next = _M_erase_after(__first); 00524 else 00525 __first = __next++; 00526 } 00527 } 00528 00529 template<typename _BinPred> 00530 void 00531 unique(_BinPred __binary_pred) 00532 { 00533 _Base_iterator __first = _Base::begin(); 00534 _Base_iterator __last = _Base::end(); 00535 if (__first == __last) 00536 return; 00537 _Base_iterator __next = std::next(__first); 00538 while (__next != __last) 00539 { 00540 if (__binary_pred(*__first, *__next)) 00541 __next = _M_erase_after(__first); 00542 else 00543 __first = __next++; 00544 } 00545 } 00546 00547 void 00548 merge(forward_list&& __list) 00549 { 00550 if (this != &__list) 00551 { 00552 __glibcxx_check_sorted(_Base::begin(), _Base::end()); 00553 __glibcxx_check_sorted(__list._M_base().begin(), 00554 __list._M_base().end()); 00555 this->_M_transfer_from_if(__list, [&__list](_Base_const_iterator __it) 00556 { 00557 return __it != __list._M_base().cbefore_begin() 00558 && __it != __list._M_base().cend(); 00559 }); 00560 _Base::merge(std::move(__list._M_base())); 00561 } 00562 } 00563 00564 template<typename _Comp> 00565 void 00566 merge(forward_list&& __list, _Comp __comp) 00567 { 00568 if (this != &__list) 00569 { 00570 __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp); 00571 __glibcxx_check_sorted_pred(__list._M_base().begin(), 00572 __list._M_base().end(), __comp); 00573 this->_M_transfer_from_if(__list, 00574 [&__list](_Base_const_iterator __it) 00575 { 00576 return __it != __list._M_base().cbefore_begin() 00577 && __it != __list._M_base().cend(); 00578 }); 00579 _Base::merge(std::move(__list._M_base()), __comp); 00580 } 00581 } 00582 00583 using _Base::sort; 00584 using _Base::reverse; 00585 00586 _Base& 00587 _M_base() noexcept { return *this; } 00588 00589 const _Base& 00590 _M_base() const noexcept { return *this; } 00591 00592 private: 00593 void 00594 _M_invalidate_all() 00595 { 00596 this->_M_invalidate_if([this](_Base_const_iterator __it) 00597 { 00598 return __it != this->_M_base().cbefore_begin() 00599 && __it != this->_M_base().cend(); 00600 }); 00601 } 00602 typedef __gnu_debug::_Safe_iterator_base _Safe_iterator_base; 00603 static void 00604 _M_swap_aux(forward_list& __lhs, 00605 _Safe_iterator_base*& __lhs_iterators, 00606 forward_list& __rhs, 00607 _Safe_iterator_base*& __rhs_iterators); 00608 void _M_swap(forward_list& __list); 00609 }; 00610 00611 template<typename _Tp, typename _Alloc> 00612 void 00613 forward_list<_Tp, _Alloc>:: 00614 _M_swap_aux(forward_list<_Tp, _Alloc>& __lhs, 00615 __gnu_debug::_Safe_iterator_base*& __lhs_iterators, 00616 forward_list<_Tp, _Alloc>& __rhs, 00617 __gnu_debug::_Safe_iterator_base*& __rhs_iterators) 00618 { 00619 using __gnu_debug::_Safe_iterator_base; 00620 _Safe_iterator_base* __bbegin_its = 0; 00621 _Safe_iterator_base* __last_bbegin = 0; 00622 for (_Safe_iterator_base* __iter = __lhs_iterators; __iter;) 00623 { 00624 // Even iterator are casted to const_iterator, not a problem. 00625 const_iterator* __victim = static_cast<const_iterator*>(__iter); 00626 __iter = __iter->_M_next; 00627 if (__victim->base() == __rhs._M_base().cbefore_begin()) 00628 { 00629 __victim->_M_unlink(); 00630 if (__lhs_iterators == __victim) 00631 __lhs_iterators = __victim->_M_next; 00632 if (__bbegin_its) 00633 { 00634 __victim->_M_next = __bbegin_its; 00635 __bbegin_its->_M_prior = __victim; 00636 } 00637 else 00638 __last_bbegin = __victim; 00639 __bbegin_its = __victim; 00640 } 00641 else 00642 __victim->_M_sequence = &__lhs; 00643 } 00644 00645 if (__bbegin_its) 00646 { 00647 if (__rhs_iterators) 00648 { 00649 __rhs_iterators->_M_prior = __last_bbegin; 00650 __last_bbegin->_M_next = __rhs_iterators; 00651 } 00652 __rhs_iterators = __bbegin_its; 00653 } 00654 } 00655 00656 /* Special forward_list _M_swap version that do not swap the 00657 * before-begin ownership.*/ 00658 template<typename _Tp, typename _Alloc> 00659 void 00660 forward_list<_Tp, _Alloc>:: 00661 _M_swap(forward_list<_Tp, _Alloc>& __list) 00662 { 00663 __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); 00664 std::swap(this->_M_iterators, __list._M_iterators); 00665 std::swap(this->_M_const_iterators, __list._M_const_iterators); 00666 // Useless, always 1 on forward_list 00667 //std::swap(this->_M_version, __list._M_version); 00668 _Safe_iterator_base* __this_its = this->_M_iterators; 00669 _M_swap_aux(__list, __list._M_iterators, *this, this->_M_iterators); 00670 _Safe_iterator_base* __this_const_its = this->_M_const_iterators; 00671 _M_swap_aux(__list, __list._M_const_iterators, *this, 00672 this->_M_const_iterators); 00673 _M_swap_aux(*this, __this_its, __list, __list._M_iterators); 00674 _M_swap_aux(*this, __this_const_its, __list, __list._M_const_iterators); 00675 } 00676 00677 template<typename _Tp, typename _Alloc> 00678 bool 00679 operator==(const forward_list<_Tp, _Alloc>& __lx, 00680 const forward_list<_Tp, _Alloc>& __ly) 00681 { return __lx._M_base() == __ly._M_base(); } 00682 00683 template<typename _Tp, typename _Alloc> 00684 inline bool 00685 operator<(const forward_list<_Tp, _Alloc>& __lx, 00686 const forward_list<_Tp, _Alloc>& __ly) 00687 { return __lx._M_base() < __ly._M_base(); } 00688 00689 template<typename _Tp, typename _Alloc> 00690 inline bool 00691 operator!=(const forward_list<_Tp, _Alloc>& __lx, 00692 const forward_list<_Tp, _Alloc>& __ly) 00693 { return !(__lx == __ly); } 00694 00695 /// Based on operator< 00696 template<typename _Tp, typename _Alloc> 00697 inline bool 00698 operator>(const forward_list<_Tp, _Alloc>& __lx, 00699 const forward_list<_Tp, _Alloc>& __ly) 00700 { return (__ly < __lx); } 00701 00702 /// Based on operator< 00703 template<typename _Tp, typename _Alloc> 00704 inline bool 00705 operator>=(const forward_list<_Tp, _Alloc>& __lx, 00706 const forward_list<_Tp, _Alloc>& __ly) 00707 { return !(__lx < __ly); } 00708 00709 /// Based on operator< 00710 template<typename _Tp, typename _Alloc> 00711 inline bool 00712 operator<=(const forward_list<_Tp, _Alloc>& __lx, 00713 const forward_list<_Tp, _Alloc>& __ly) 00714 { return !(__ly < __lx); } 00715 00716 /// See std::forward_list::swap(). 00717 template<typename _Tp, typename _Alloc> 00718 inline void 00719 swap(forward_list<_Tp, _Alloc>& __lx, 00720 forward_list<_Tp, _Alloc>& __ly) 00721 { __lx.swap(__ly); } 00722 00723 } // namespace __debug 00724 } // namespace std 00725 00726 namespace __gnu_debug 00727 { 00728 template<class _Tp, class _Alloc> 00729 struct _BeforeBeginHelper<std::__debug::forward_list<_Tp, _Alloc> > 00730 { 00731 typedef std::__debug::forward_list<_Tp, _Alloc> _Sequence; 00732 typedef typename _Sequence::const_iterator _It; 00733 typedef typename _It::iterator_type _BaseIt; 00734 00735 static bool 00736 _M_Is(_BaseIt __it, const _Sequence* __seq) 00737 { return __it == __seq->_M_base().cbefore_begin(); } 00738 }; 00739 } 00740 00741 #endif