1 // Debugging list implementation -*- C++ -*-
3 // Copyright (C) 2003-2020 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
26 * This file is a GNU debug extension to the Standard C++ Library.
29 #ifndef _GLIBCXX_DEBUG_LIST
30 #define _GLIBCXX_DEBUG_LIST 1
32 #pragma GCC system_header
34 #include <bits/c++config.h>
35 namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
36 template<typename _Tp, typename _Allocator> class list;
37 } } // namespace std::__debug
40 #include <debug/safe_sequence.h>
41 #include <debug/safe_container.h>
42 #include <debug/safe_iterator.h>
44 namespace std _GLIBCXX_VISIBILITY(default)
48 /// Class std::list with safety/checking/debug instrumentation.
49 template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
51 : public __gnu_debug::_Safe_container<
52 list<_Tp, _Allocator>, _Allocator,
53 __gnu_debug::_Safe_node_sequence>,
54 public _GLIBCXX_STD_C::list<_Tp, _Allocator>
56 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base;
57 typedef __gnu_debug::_Safe_container<
58 list, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
60 typedef typename _Base::iterator _Base_iterator;
61 typedef typename _Base::const_iterator _Base_const_iterator;
62 typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
63 typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
65 template<typename _ItT, typename _SeqT, typename _CatT>
66 friend class ::__gnu_debug::_Safe_iterator;
69 typedef typename _Base::reference reference;
70 typedef typename _Base::const_reference const_reference;
72 typedef __gnu_debug::_Safe_iterator<_Base_iterator, list>
74 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, list>
77 typedef typename _Base::size_type size_type;
78 typedef typename _Base::difference_type difference_type;
80 typedef _Tp value_type;
81 typedef _Allocator allocator_type;
82 typedef typename _Base::pointer pointer;
83 typedef typename _Base::const_pointer const_pointer;
84 typedef std::reverse_iterator<iterator> reverse_iterator;
85 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
87 // 23.2.2.1 construct/copy/destroy:
89 #if __cplusplus < 201103L
99 list(const list&) = default;
100 list(list&&) = default;
102 list(initializer_list<value_type> __l,
103 const allocator_type& __a = allocator_type())
104 : _Base(__l, __a) { }
108 list(const list& __x, const allocator_type& __a)
109 : _Base(__x, __a) { }
111 list(list&& __x, const allocator_type& __a)
112 : _Base(std::move(__x), __a) { }
116 list(const _Allocator& __a) _GLIBCXX_NOEXCEPT
119 #if __cplusplus >= 201103L
121 list(size_type __n, const allocator_type& __a = allocator_type())
122 : _Base(__n, __a) { }
124 list(size_type __n, const _Tp& __value,
125 const _Allocator& __a = _Allocator())
126 : _Base(__n, __value, __a) { }
129 list(size_type __n, const _Tp& __value = _Tp(),
130 const _Allocator& __a = _Allocator())
131 : _Base(__n, __value, __a) { }
134 #if __cplusplus >= 201103L
135 template<class _InputIterator,
136 typename = std::_RequireInputIter<_InputIterator>>
138 template<class _InputIterator>
140 list(_InputIterator __first, _InputIterator __last,
141 const _Allocator& __a = _Allocator())
142 : _Base(__gnu_debug::__base(
143 __glibcxx_check_valid_constructor_range(__first, __last)),
144 __gnu_debug::__base(__last), __a)
147 list(const _Base& __x)
150 #if __cplusplus < 201103L
152 operator=(const list& __x)
154 this->_M_safe() = __x;
160 operator=(const list&) = default;
163 operator=(list&&) = default;
166 operator=(initializer_list<value_type> __l)
168 this->_M_invalidate_all();
174 assign(initializer_list<value_type> __l)
177 this->_M_invalidate_all();
181 #if __cplusplus >= 201103L
182 template<class _InputIterator,
183 typename = std::_RequireInputIter<_InputIterator>>
185 template<class _InputIterator>
188 assign(_InputIterator __first, _InputIterator __last)
190 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
191 __glibcxx_check_valid_range2(__first, __last, __dist);
193 if (__dist.second >= __gnu_debug::__dp_sign)
194 _Base::assign(__gnu_debug::__unsafe(__first),
195 __gnu_debug::__unsafe(__last));
197 _Base::assign(__first, __last);
199 this->_M_invalidate_all();
203 assign(size_type __n, const _Tp& __t)
205 _Base::assign(__n, __t);
206 this->_M_invalidate_all();
209 using _Base::get_allocator;
213 begin() _GLIBCXX_NOEXCEPT
214 { return iterator(_Base::begin(), this); }
217 begin() const _GLIBCXX_NOEXCEPT
218 { return const_iterator(_Base::begin(), this); }
221 end() _GLIBCXX_NOEXCEPT
222 { return iterator(_Base::end(), this); }
225 end() const _GLIBCXX_NOEXCEPT
226 { return const_iterator(_Base::end(), this); }
229 rbegin() _GLIBCXX_NOEXCEPT
230 { return reverse_iterator(end()); }
232 const_reverse_iterator
233 rbegin() const _GLIBCXX_NOEXCEPT
234 { return const_reverse_iterator(end()); }
237 rend() _GLIBCXX_NOEXCEPT
238 { return reverse_iterator(begin()); }
240 const_reverse_iterator
241 rend() const _GLIBCXX_NOEXCEPT
242 { return const_reverse_iterator(begin()); }
244 #if __cplusplus >= 201103L
246 cbegin() const noexcept
247 { return const_iterator(_Base::begin(), this); }
250 cend() const noexcept
251 { return const_iterator(_Base::end(), this); }
253 const_reverse_iterator
254 crbegin() const noexcept
255 { return const_reverse_iterator(end()); }
257 const_reverse_iterator
258 crend() const noexcept
259 { return const_reverse_iterator(begin()); }
262 // 23.2.2.2 capacity:
265 using _Base::max_size;
267 #if __cplusplus >= 201103L
269 resize(size_type __sz)
271 this->_M_detach_singular();
273 // if __sz < size(), invalidate all iterators in [begin + __sz, end())
274 _Base_iterator __victim = _Base::begin();
275 _Base_iterator __end = _Base::end();
276 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
279 for (; __victim != __end; ++__victim)
280 this->_M_invalidate_if(_Equal(__victim));
288 this->_M_revalidate_singular();
289 __throw_exception_again;
294 resize(size_type __sz, const _Tp& __c)
296 this->_M_detach_singular();
298 // if __sz < size(), invalidate all iterators in [begin + __sz, end())
299 _Base_iterator __victim = _Base::begin();
300 _Base_iterator __end = _Base::end();
301 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
304 for (; __victim != __end; ++__victim)
305 this->_M_invalidate_if(_Equal(__victim));
309 _Base::resize(__sz, __c);
313 this->_M_revalidate_singular();
314 __throw_exception_again;
319 resize(size_type __sz, _Tp __c = _Tp())
321 this->_M_detach_singular();
323 // if __sz < size(), invalidate all iterators in [begin + __sz, end())
324 _Base_iterator __victim = _Base::begin();
325 _Base_iterator __end = _Base::end();
326 for (size_type __i = __sz; __victim != __end && __i > 0; --__i)
329 for (; __victim != __end; ++__victim)
330 this->_M_invalidate_if(_Equal(__victim));
334 _Base::resize(__sz, __c);
338 this->_M_revalidate_singular();
339 __throw_exception_again;
346 front() _GLIBCXX_NOEXCEPT
348 __glibcxx_check_nonempty();
349 return _Base::front();
353 front() const _GLIBCXX_NOEXCEPT
355 __glibcxx_check_nonempty();
356 return _Base::front();
360 back() _GLIBCXX_NOEXCEPT
362 __glibcxx_check_nonempty();
363 return _Base::back();
367 back() const _GLIBCXX_NOEXCEPT
369 __glibcxx_check_nonempty();
370 return _Base::back();
373 // 23.2.2.3 modifiers:
374 using _Base::push_front;
376 #if __cplusplus >= 201103L
377 using _Base::emplace_front;
381 pop_front() _GLIBCXX_NOEXCEPT
383 __glibcxx_check_nonempty();
384 this->_M_invalidate_if(_Equal(_Base::begin()));
388 using _Base::push_back;
390 #if __cplusplus >= 201103L
391 using _Base::emplace_back;
395 pop_back() _GLIBCXX_NOEXCEPT
397 __glibcxx_check_nonempty();
398 this->_M_invalidate_if(_Equal(--_Base::end()));
402 #if __cplusplus >= 201103L
403 template<typename... _Args>
405 emplace(const_iterator __position, _Args&&... __args)
407 __glibcxx_check_insert(__position);
408 return { _Base::emplace(__position.base(),
409 std::forward<_Args>(__args)...), this };
414 #if __cplusplus >= 201103L
415 insert(const_iterator __position, const _Tp& __x)
417 insert(iterator __position, const _Tp& __x)
420 __glibcxx_check_insert(__position);
421 return iterator(_Base::insert(__position.base(), __x), this);
424 #if __cplusplus >= 201103L
426 insert(const_iterator __position, _Tp&& __x)
427 { return emplace(__position, std::move(__x)); }
430 insert(const_iterator __p, initializer_list<value_type> __l)
432 __glibcxx_check_insert(__p);
433 return { _Base::insert(__p.base(), __l), this };
437 #if __cplusplus >= 201103L
439 insert(const_iterator __position, size_type __n, const _Tp& __x)
441 __glibcxx_check_insert(__position);
442 return { _Base::insert(__position.base(), __n, __x), this };
446 insert(iterator __position, size_type __n, const _Tp& __x)
448 __glibcxx_check_insert(__position);
449 _Base::insert(__position.base(), __n, __x);
453 #if __cplusplus >= 201103L
454 template<class _InputIterator,
455 typename = std::_RequireInputIter<_InputIterator>>
457 insert(const_iterator __position, _InputIterator __first,
458 _InputIterator __last)
460 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
461 __glibcxx_check_insert_range(__position, __first, __last, __dist);
462 if (__dist.second >= __gnu_debug::__dp_sign)
465 _Base::insert(__position.base(),
466 __gnu_debug::__unsafe(__first),
467 __gnu_debug::__unsafe(__last)),
471 return { _Base::insert(__position.base(), __first, __last), this };
474 template<class _InputIterator>
476 insert(iterator __position, _InputIterator __first,
477 _InputIterator __last)
479 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
480 __glibcxx_check_insert_range(__position, __first, __last, __dist);
482 if (__dist.second >= __gnu_debug::__dp_sign)
483 _Base::insert(__position.base(), __gnu_debug::__unsafe(__first),
484 __gnu_debug::__unsafe(__last));
486 _Base::insert(__position.base(), __first, __last);
492 #if __cplusplus >= 201103L
493 _M_erase(_Base_const_iterator __position) noexcept
495 _M_erase(_Base_iterator __position)
498 this->_M_invalidate_if(_Equal(__position));
499 return _Base::erase(__position);
504 #if __cplusplus >= 201103L
505 erase(const_iterator __position) noexcept
507 erase(iterator __position)
510 __glibcxx_check_erase(__position);
511 return iterator(_M_erase(__position.base()), this);
515 #if __cplusplus >= 201103L
516 erase(const_iterator __first, const_iterator __last) noexcept
518 erase(iterator __first, iterator __last)
521 // _GLIBCXX_RESOLVE_LIB_DEFECTS
522 // 151. can't currently clear() empty container
523 __glibcxx_check_erase_range(__first, __last);
524 for (_Base_const_iterator __victim = __first.base();
525 __victim != __last.base(); ++__victim)
527 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
528 _M_message(__gnu_debug::__msg_valid_range)
529 ._M_iterator(__first, "position")
530 ._M_iterator(__last, "last"));
531 this->_M_invalidate_if(_Equal(__victim));
534 return iterator(_Base::erase(__first.base(), __last.base()), this);
539 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
546 clear() _GLIBCXX_NOEXCEPT
549 this->_M_invalidate_all();
552 // 23.2.2.4 list operations:
554 #if __cplusplus >= 201103L
555 splice(const_iterator __position, list&& __x) noexcept
557 splice(iterator __position, list& __x)
560 _GLIBCXX_DEBUG_VERIFY(std::__addressof(__x) != this,
561 _M_message(__gnu_debug::__msg_self_splice)
562 ._M_sequence(*this, "this"));
563 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
564 _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()));
567 #if __cplusplus >= 201103L
569 splice(const_iterator __position, list& __x) noexcept
570 { splice(__position, std::move(__x)); }
574 #if __cplusplus >= 201103L
575 splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
577 splice(iterator __position, list& __x, iterator __i)
580 __glibcxx_check_insert(__position);
582 // We used to perform the splice_alloc check: not anymore, redundant
583 // after implementing the relevant bits of N1599.
585 _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(),
586 _M_message(__gnu_debug::__msg_splice_bad)
587 ._M_iterator(__i, "__i"));
588 _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(std::__addressof(__x)),
589 _M_message(__gnu_debug::__msg_splice_other)
590 ._M_iterator(__i, "__i")._M_sequence(__x, "__x"));
592 // _GLIBCXX_RESOLVE_LIB_DEFECTS
593 // 250. splicing invalidates iterators
594 this->_M_transfer_from_if(__x, _Equal(__i.base()));
595 _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
599 #if __cplusplus >= 201103L
601 splice(const_iterator __position, list& __x, const_iterator __i) noexcept
602 { splice(__position, std::move(__x), __i); }
606 #if __cplusplus >= 201103L
607 splice(const_iterator __position, list&& __x, const_iterator __first,
608 const_iterator __last) noexcept
610 splice(iterator __position, list& __x, iterator __first,
614 __glibcxx_check_insert(__position);
615 __glibcxx_check_valid_range(__first, __last);
616 _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(std::__addressof(__x)),
617 _M_message(__gnu_debug::__msg_splice_other)
618 ._M_sequence(__x, "x")
619 ._M_iterator(__first, "first"));
621 // We used to perform the splice_alloc check: not anymore, redundant
622 // after implementing the relevant bits of N1599.
624 for (_Base_const_iterator __tmp = __first.base();
625 __tmp != __last.base(); ++__tmp)
627 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
628 _M_message(__gnu_debug::__msg_valid_range)
629 ._M_iterator(__first, "first")
630 ._M_iterator(__last, "last"));
631 _GLIBCXX_DEBUG_VERIFY(std::__addressof(__x) != this
632 || __tmp != __position.base(),
633 _M_message(__gnu_debug::__msg_splice_overlap)
634 ._M_iterator(__tmp, "position")
635 ._M_iterator(__first, "first")
636 ._M_iterator(__last, "last"));
638 // _GLIBCXX_RESOLVE_LIB_DEFECTS
639 // 250. splicing invalidates iterators
640 this->_M_transfer_from_if(__x, _Equal(__tmp));
643 _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
644 __first.base(), __last.base());
647 #if __cplusplus >= 201103L
649 splice(const_iterator __position, list& __x,
650 const_iterator __first, const_iterator __last) noexcept
651 { splice(__position, std::move(__x), __first, __last); }
655 #if __cplusplus > 201703L
656 typedef size_type __remove_return_type;
657 # define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \
658 __attribute__((__abi_tag__("__cxx20")))
659 # define _GLIBCXX20_ONLY(__expr) __expr
661 typedef void __remove_return_type;
662 # define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
663 # define _GLIBCXX20_ONLY(__expr)
667 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
669 remove(const _Tp& __value)
671 if (!this->_M_iterators && !this->_M_const_iterators)
672 return _Base::remove(__value);
674 size_type __removed __attribute__((__unused__)) = 0;
675 _Base_iterator __first = _Base::begin();
676 _Base_iterator __last = _Base::end();
677 _Base_iterator __extra = __last;
678 while (__first != __last)
680 if (*__first == __value)
681 // _GLIBCXX_RESOLVE_LIB_DEFECTS
682 // 526. Is it undefined if a function in the standard changes
684 if (std::__addressof(*__first) != std::__addressof(__value))
686 __first = _M_erase(__first);
687 _GLIBCXX20_ONLY( __removed++ );
698 if (__extra != __last)
701 _GLIBCXX20_ONLY( __removed++ );
703 return _GLIBCXX20_ONLY( __removed );
706 template<class _Predicate>
708 remove_if(_Predicate __pred)
710 if (!this->_M_iterators && !this->_M_const_iterators)
711 return _Base::remove_if(__pred);
713 size_type __removed __attribute__((__unused__)) = 0;
714 for (_Base_iterator __x = _Base::begin(); __x != _Base::end(); )
718 _GLIBCXX20_ONLY( __removed++ );
723 return _GLIBCXX20_ONLY( __removed );
726 _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
730 if (!this->_M_iterators && !this->_M_const_iterators)
731 return _Base::unique();
734 return _GLIBCXX20_ONLY(0);
736 size_type __removed __attribute__((__unused__)) = 0;
737 _Base_iterator __first = _Base::begin();
738 _Base_iterator __last = _Base::end();
739 _Base_iterator __next = __first;
740 while (++__next != __last)
741 if (*__first == *__next)
745 _GLIBCXX20_ONLY( __removed++ );
750 return _GLIBCXX20_ONLY( __removed );
753 template<class _BinaryPredicate>
755 unique(_BinaryPredicate __binary_pred)
757 if (!this->_M_iterators && !this->_M_const_iterators)
758 return _Base::unique(__binary_pred);
761 return _GLIBCXX20_ONLY(0);
763 size_type __removed __attribute__((__unused__)) = 0;
764 _Base_iterator __first = _Base::begin();
765 _Base_iterator __last = _Base::end();
766 _Base_iterator __next = __first;;
767 while (++__next != __last)
768 if (__binary_pred(*__first, *__next))
772 _GLIBCXX20_ONLY( __removed++ );
777 return _GLIBCXX20_ONLY( __removed );
780 #undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
781 #undef _GLIBCXX20_ONLY
784 #if __cplusplus >= 201103L
790 // _GLIBCXX_RESOLVE_LIB_DEFECTS
791 // 300. list::merge() specification incomplete
792 if (this != std::__addressof(__x))
794 __glibcxx_check_sorted(_Base::begin(), _Base::end());
795 __glibcxx_check_sorted(__x.begin().base(), __x.end().base());
796 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
797 _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
801 #if __cplusplus >= 201103L
804 { merge(std::move(__x)); }
807 template<class _Compare>
809 #if __cplusplus >= 201103L
810 merge(list&& __x, _Compare __comp)
812 merge(list& __x, _Compare __comp)
815 // _GLIBCXX_RESOLVE_LIB_DEFECTS
816 // 300. list::merge() specification incomplete
817 if (this != std::__addressof(__x))
819 __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(),
821 __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(),
823 this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
824 _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
828 #if __cplusplus >= 201103L
829 template<typename _Compare>
831 merge(list& __x, _Compare __comp)
832 { merge(std::move(__x), __comp); }
836 sort() { _Base::sort(); }
838 template<typename _StrictWeakOrdering>
840 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
842 using _Base::reverse;
845 _M_base() _GLIBCXX_NOEXCEPT { return *this; }
848 _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
851 #if __cpp_deduction_guides >= 201606
852 template<typename _InputIterator, typename _ValT
853 = typename iterator_traits<_InputIterator>::value_type,
854 typename _Allocator = allocator<_ValT>,
855 typename = _RequireInputIter<_InputIterator>,
856 typename = _RequireAllocator<_Allocator>>
857 list(_InputIterator, _InputIterator, _Allocator = _Allocator())
858 -> list<_ValT, _Allocator>;
861 template<typename _Tp, typename _Alloc>
863 operator==(const list<_Tp, _Alloc>& __lhs,
864 const list<_Tp, _Alloc>& __rhs)
865 { return __lhs._M_base() == __rhs._M_base(); }
867 #if __cpp_lib_three_way_comparison
868 template<typename _Tp, typename _Alloc>
869 constexpr __detail::__synth3way_t<_Tp>
870 operator<=>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
871 { return __x._M_base() <=> __y._M_base(); }
873 template<typename _Tp, typename _Alloc>
875 operator!=(const list<_Tp, _Alloc>& __lhs,
876 const list<_Tp, _Alloc>& __rhs)
877 { return __lhs._M_base() != __rhs._M_base(); }
879 template<typename _Tp, typename _Alloc>
881 operator<(const list<_Tp, _Alloc>& __lhs,
882 const list<_Tp, _Alloc>& __rhs)
883 { return __lhs._M_base() < __rhs._M_base(); }
885 template<typename _Tp, typename _Alloc>
887 operator<=(const list<_Tp, _Alloc>& __lhs,
888 const list<_Tp, _Alloc>& __rhs)
889 { return __lhs._M_base() <= __rhs._M_base(); }
891 template<typename _Tp, typename _Alloc>
893 operator>=(const list<_Tp, _Alloc>& __lhs,
894 const list<_Tp, _Alloc>& __rhs)
895 { return __lhs._M_base() >= __rhs._M_base(); }
897 template<typename _Tp, typename _Alloc>
899 operator>(const list<_Tp, _Alloc>& __lhs,
900 const list<_Tp, _Alloc>& __rhs)
901 { return __lhs._M_base() > __rhs._M_base(); }
902 #endif // three-way comparison
904 template<typename _Tp, typename _Alloc>
906 swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
907 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
908 { __lhs.swap(__rhs); }
910 } // namespace __debug
913 namespace __gnu_debug
915 #ifndef _GLIBCXX_USE_CXX11_ABI
916 // If not using C++11 list::size() is not in O(1) so we do not use it.
917 template<typename _Tp, typename _Alloc>
918 struct _Sequence_traits<std::__debug::list<_Tp, _Alloc> >
920 typedef typename std::__debug::list<_Tp, _Alloc>::iterator _It;
922 static typename _Distance_traits<_It>::__type
923 _S_size(const std::__debug::list<_Tp, _Alloc>& __seq)
926 ? std::make_pair(0, __dp_exact) : std::make_pair(1, __dp_sign);
931 #ifndef _GLIBCXX_DEBUG_PEDANTIC
932 template<class _Tp, class _Alloc>
933 struct _Insert_range_from_self_is_safe<std::__debug::list<_Tp, _Alloc> >
934 { enum { __value = 1 }; };