// Debugging list implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/list * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_LIST #define _GLIBCXX_DEBUG_LIST 1 #include #include #include #include namespace std { namespace __debug { template > class list : public _GLIBCXX_STD_D::list<_Tp, _Allocator>, public __gnu_debug::_Safe_sequence > { typedef _GLIBCXX_STD_D::list<_Tp, _Allocator> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; public: typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; typedef __gnu_debug::_Safe_iterator const_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef _Tp value_type; typedef _Allocator allocator_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // 23.2.2.1 construct/copy/destroy: explicit list(const _Allocator& __a = _Allocator()) : _Base(__a) { } explicit list(size_type __n, const _Tp& __value = _Tp(), const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } template list(_InputIterator __first, _InputIterator __last, const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __a) { } list(const list& __x) : _Base(__x), _Safe_base() { } list(const _Base& __x) : _Base(__x), _Safe_base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ list(list&& __x) : _Base(std::forward(__x)), _Safe_base() { this->_M_swap(__x); } #endif ~list() { } list& operator=(const list& __x) { static_cast<_Base&>(*this) = __x; this->_M_invalidate_all(); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ list& operator=(list&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } #endif template void assign(_InputIterator __first, _InputIterator __last) { __glibcxx_check_valid_range(__first, __last); _Base::assign(__first, __last); this->_M_invalidate_all(); } void assign(size_type __n, const _Tp& __t) { _Base::assign(__n, __t); this->_M_invalidate_all(); } using _Base::get_allocator; // iterators: iterator begin() { return iterator(_Base::begin(), this); } const_iterator begin() const { return const_iterator(_Base::begin(), this); } iterator end() { return iterator(_Base::end(), this); } const_iterator end() const { return const_iterator(_Base::end(), this); } reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ const_iterator cbegin() const { return const_iterator(_Base::begin(), this); } const_iterator cend() const { return const_iterator(_Base::end(), this); } const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } #endif // 23.2.2.2 capacity: using _Base::empty; using _Base::size; using _Base::max_size; void resize(size_type __sz, _Tp __c = _Tp()) { this->_M_detach_singular(); // if __sz < size(), invalidate all iterators in [begin+__sz, end()) iterator __victim = begin(); iterator __end = end(); for (size_type __i = __sz; __victim != __end && __i > 0; --__i) ++__victim; while (__victim != __end) { iterator __real_victim = __victim++; __real_victim._M_invalidate(); } try { _Base::resize(__sz, __c); } catch(...) { this->_M_revalidate_singular(); __throw_exception_again; } } // element access: reference front() { __glibcxx_check_nonempty(); return _Base::front(); } const_reference front() const { __glibcxx_check_nonempty(); return _Base::front(); } reference back() { __glibcxx_check_nonempty(); return _Base::back(); } const_reference back() const { __glibcxx_check_nonempty(); return _Base::back(); } // 23.2.2.3 modifiers: using _Base::push_front; void pop_front() { __glibcxx_check_nonempty(); iterator __victim = begin(); __victim._M_invalidate(); _Base::pop_front(); } using _Base::push_back; void pop_back() { __glibcxx_check_nonempty(); iterator __victim = end(); --__victim; __victim._M_invalidate(); _Base::pop_back(); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template iterator emplace(iterator __position, _Args&&... __args) { __glibcxx_check_insert(__position); return iterator(_Base::emplace(__position.base(), std::forward<_Args>(__args)...), this); } #endif iterator insert(iterator __position, const _Tp& __x) { __glibcxx_check_insert(__position); return iterator(_Base::insert(__position.base(), __x), this); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator insert(iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } #endif void insert(iterator __position, size_type __n, const _Tp& __x) { __glibcxx_check_insert(__position); _Base::insert(__position.base(), __n, __x); } template void insert(iterator __position, _InputIterator __first, _InputIterator __last) { __glibcxx_check_insert_range(__position, __first, __last); _Base::insert(__position.base(), __first, __last); } iterator erase(iterator __position) { __glibcxx_check_erase(__position); __position._M_invalidate(); return iterator(_Base::erase(__position.base()), this); } iterator erase(iterator __position, iterator __last) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container __glibcxx_check_erase_range(__position, __last); for (iterator __victim = __position; __victim != __last; ) { iterator __old = __victim; ++__victim; __old._M_invalidate(); } return iterator(_Base::erase(__position.base(), __last.base()), this); } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ swap(list&& __x) #else swap(list& __x) #endif { _Base::swap(__x); this->_M_swap(__x); } void clear() { _Base::clear(); this->_M_invalidate_all(); } // 23.2.2.4 list operations: void #ifdef __GXX_EXPERIMENTAL_CXX0X__ splice(iterator __position, list&& __x) #else splice(iterator __position, list& __x) #endif { _GLIBCXX_DEBUG_VERIFY(&__x != this, _M_message(__gnu_debug::__msg_self_splice) ._M_sequence(*this, "this")); this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ splice(iterator __position, list&& __x, iterator __i) #else splice(iterator __position, list& __x, iterator __i) #endif { __glibcxx_check_insert(__position); // We used to perform the splice_alloc check: not anymore, redundant // after implementing the relevant bits of N1599. _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(), _M_message(__gnu_debug::__msg_splice_bad) ._M_iterator(__i, "__i")); _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(&__x), _M_message(__gnu_debug::__msg_splice_other) ._M_iterator(__i, "__i")._M_sequence(__x, "__x")); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 250. splicing invalidates iterators this->_M_transfer_iter(__i); _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), __i.base()); } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ splice(iterator __position, list&& __x, iterator __first, iterator __last) #else splice(iterator __position, list& __x, iterator __first, iterator __last) #endif { __glibcxx_check_insert(__position); __glibcxx_check_valid_range(__first, __last); _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(&__x), _M_message(__gnu_debug::__msg_splice_other) ._M_sequence(__x, "x") ._M_iterator(__first, "first")); // We used to perform the splice_alloc check: not anymore, redundant // after implementing the relevant bits of N1599. for (iterator __tmp"Ž"""‘" = __first; __tmp != __last; ) { _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position, _M_message(__gnu_debug::__msg_splice_overlap) ._M_iterator(__tmp, "position") ._M_iterator(__first, "first") ._M_iterator(__last, "last")); iterator __victim = __tmp++; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 250. splicing invalidates iterators this->_M_transfer_iter(__victim); } _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), __first.base(), __last.base()); } void remove(const _Tp& __value) { for (iterator __x = begin(); __x.base() != _Base::end(); ) { if (*__x == __value) __x = erase(__x); else ++__x; } } template void remove_if(_Predicate __pred) { for (iterator __x = begin(); __x.base() != _Base::end(); ) { if (__pred(*__x)) __x = erase(__x); else ++__x; } } void unique() { iterator __first = begin(); iterator __last = end(); if (__first == __last) return; iterator __next = __first; while (++__next != __last) { if (*__first == *__next) erase(__next); else __first = __next; __next = __first; } } template void unique(_BinaryPredicate __binary_pred) { iterator __first = begin(); iterator __last = end(); if (__first == __last) return; iterator __next = __first; while (++__next != __last) { if (__binary_pred(*__first, *__next)) erase(__next); else __first = __next; __next = __first; } } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ merge(list&& __x) #else merge(list& __x) #endif { __glibcxx_check_sorted(_Base::begin(), _Base::end()); __glibcxx_check_sorted(__x.begin().base(), __x.end().base()); for (iterator __tmp = __x.begin(); __tmp != __x.end(); ) { iterator __victim = __tmp++; __victim._M_attach(&__x); } _Base::merge(_GLIBCXX_MOVE(__x._M_base())); } template void #ifdef __GXX_EXPERIMENTAL_CXX0X__ merge(list&& __x, _Compare __comp) #else merge(list& __x, _Compare __comp) #endif { __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp); __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(), __comp); for (iterator __tmp = __x.begin(); __tmp != __x.end(); ) { iterator __victim = __tmp++; __victim._M_attach(&__x); } _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); } void sort() { _Base::sort(); } template void sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); } using _Base::reverse; _Base& _M_base() { return *this; } const _Base& _M_base() const { return *this; } private: void _M_invalidate_all() { typedef typename _Base::const_iterator _Base_const_iterator; typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal; this->_M_invalidate_if(_Not_equal(_M_base().end())); } }; template inline bool operator==(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const list<_Tp, _Alloc>& __lhs, const list<_Tp, _Alloc>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template inline void swap(list<_Tp, _Alloc>&& __lhs, list<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } template inline void swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>&& __rhs) { __lhs.swap(__rhs); } #endif } // namespace __debug } // namespace std #endif // Debugging bitset implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/bitset * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_BITSET #define _GLIBCXX_DEBUG_BITSET #include #include #include namespace std { namespace __debug { template class bitset : public _GLIBCXX_STD_D::bitset<_Nb>, public __gnu_debug::_Safe_sequence_base { typedef _GLIBCXX_STD_D::bitset<_Nb> _Base; typedef __gnu_debug::_Safe_sequence_base _Safe_base; public: // bit reference: class reference : private _Base::reference, public __gnu_debug::_Safe_iterator_base { typedef typename _Base::reference _Base_ref; friend class bitset; reference(); reference(const _Base_ref& __base, bitset* __seq) : _Base_ref(__base), _Safe_iterator_base(__seq, false) { } public: reference(const reference& __x) : _Base_ref(__x), _Safe_iterator_base(__x, false) { } reference& operator=(bool __x) { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); *static_cast<_Base_ref*>(this) = __x; return *this; } reference& operator=(const reference& __x) { _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(__x)); _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_write) ._M_iterator(*this)); *static_cast<_Base_ref*>(this) = __x; return *this; } bool operator~() const { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); return ~(*static_cast(this)); } operator bool() const { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_read) ._M_iterator(*this)); return *static_cast(this); } reference& flip() { _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(), _M_message(__gnu_debug::__msg_bad_bitset_flip) ._M_iterator(*this)); _Base_ref::flip(); return *this; } }; // 23.3.5.1 constructors: bitset() : _Base() { } bitset(unsigned long __val) : _Base(__val) { } template explicit bitset(const std::basic_string<_CharT,_Traits,_Allocator>& __str, typename std::basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0, typename std::basic_string<_CharT,_Traits,_Allocator>::size_type __n = (std::basic_string<_CharT,_Traits,_Allocator>::npos)) : _Base(__str, __pos, __n) { } bitset(const _Base& __x) : _Base(__x), _Safe_base() { } // 23.3.5.2 bitset operations: bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) { _M_base() &= __rhs; return *this; } bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) { _M_base() |= __rhs; return *this; } bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) { _M_base() ^= __rhs; return *this; } bitset<_Nb>& operator<<=(size_t __pos) { _M_base() <<= __pos; return *this; } bitset<_Nb>& operator>>=(size_t __pos) { _M_base() >>= __pos; return *this; } bitset<_Nb>& set() { _Base::set(); return *this; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 186. bitset::set() second parameter should be bool bitset<_Nb>& set(size_t __pos, bool __val = true) { _Base::set(__pos, __val); return *this; } bitset<_Nb>& reset() { _Base::reset(); return *this; } bitset<_Nb>& reset(size_t __pos) { _Base::reset(__pos); return *this; } bitset<_Nb> operator~() const { return bitset(~_M_base()); } bitset<_Nb>& flip() { _Base::flip(); return *this; } bitset<_Nb>& flip(size_t __pos) { _Base::flip(__pos); return *this; } // element access: // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems reference operator[](size_t __pos) { __glibcxx_check_subscript(__pos); return reference(_M_base()[__pos], this); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems bool operator[](size_t __pos) const { __glibcxx_check_subscript(__pos); return _M_base()[__pos]; } using _Base::to_ulong; template std::basic_string<_CharT, _Traits, _Allocator> to_string() const { return _M_base().template to_string<_CharT, _Traits, _Allocator>(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 434. bitset::to_string() hard to use. template std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string() const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } template std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string() const { return to_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> >(); } std::basic_string, std::allocator > to_string() const { return to_string,std::allocator >(); } using _Base::count; using _Base::size; bool operator==(const bitset<_Nb>& __rhs) const { return _M_base() == __rhs; } bool operator!=(const bitset<_Nb>& __rhs) const { return _M_base() != __rhs; } using _Base::test; using _Base::all; using _Base::any; using _Base::none; bitset<_Nb> operator<<(size_t __pos) const { return bitset<_Nb>(_M_base() << __pos); } bitset<_Nb> operator>>(size_t __pos) const { return bitset<_Nb>(_M_base() >> __pos); } _Base& _M_base() { return *this; } const _Base& _M_base() const { return *this; } }; template bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) { return bitset<_Nb>(__x) &= __y; } template bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) { return bitset<_Nb>(__x) |= __y; } template bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) { return bitset<_Nb>(__x) ^= __y; } template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) { return __is >> __x._M_base(); } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) { return __os << __x._M_base(); } } // namespace __debug } // namespace std #endif // Debugging deque implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/deque * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_DEQUE #define _GLIBCXX_DEBUG_DEQUE 1 #include #include #include namespace std { namespace __debug { template > class deque : public _GLIBCXX_STD_D::deque<_Tp, _Allocator>, public __gnu_debug::_Safe_sequence > { typedef _GLIBCXX_STD_D::deque<_Tp, _Allocator> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; public: typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; typedef __gnu_debug::_Safe_iterator const_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef _Tp value_type; typedef _Allocator allocator_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // 23.2.1.1 construct/copy/destroy: explicit deque(const _Allocator& __a = _Allocator()) : _Base(__a) { } explicit deque(size_type __n, const _Tp& __value = _Tp(), const _Allocator& __a = _Allocator()) : _Base(__n, __value, __a) { } template deque(_InputIterator __first, _InputIterator __last, const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __a) { } deque(const deque& __x) : _Base(__x), _Safe_base() { } deque(const _Base& __x) : _Base(__x), _Safe_base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ deque(deque&& __x) : _Base(std::forward(__x)), _Safe_base() { this->_M_swap(__x); } #endif ~deque() { } deque& operator=(const deque& __x) { *static_cast<_Base*>(this) = __x; this->_M_invalidate_all(); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ deque& operator=(deque&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } #endif template void assign(_InputIterator __first, _InputIterator __last) { __glibcxx_check_valid_range(__first, __last); _Base::assign(__first, __last); this->_M_invalidate_all(); } void assign(size_type __n, const _Tp& __t) { _Base::assign(__n, __t); this->_M_invalidate_all(); } using _Base::get_allocator; // iterators: iterator begin() { return iterator(_Base::begin(), this); } const_iterator begin() const { return const_iterator(_Base::begin(), this); } iterator end() { return iterator(_Base::end(), this); } const_iterator end() const { return const_iterator(_Base::end(), this); } reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ const_iterator cbegin() const { return const_iterator(_Base::begin(), this); } const_iterator cend() const { return const_iterator(_Base::end(), this); } const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } #endif // 23.2.1.2 capacity: using _Base::size; using _Base::max_size; void resize(size_type __sz, _Tp __c = _Tp()) { typedef typename _Base::const_iterator _Base_const_iterator; typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth; bool __invalidate_all = __sz > this->size(); if (__sz < this->size()) this->_M_invalidate_if(_After_nth(__sz, _M_base().begin())); _Base::resize(__sz, __c); if (__invalidate_all) this->_M_invalidate_all(); } using _Base::empty; // element access: reference operator[](size_type __n) { __glibcxx_check_subscript(__n); return _M_base()[__n]; } const_reference operator[](size_type __n) const { __glibcxx_check_subscript(__n); return _M_base()[__n]; } using _Base::at; reference front() { __glibcxx_check_nonempty(); return _Base::front(); } const_reference front() const { __glibcxx_check_nonempty(); return _Base::front(); } reference back() { __glibcxx_check_nonempty(); return _Base::back(); } const_reference back() const { __glibcxx_check_nonempty(); return _Base::back(); } // 23.2.1.3 modifiers: #ifndef __GXX_EXPERIMENTAL_CXX0X__ void push_front(const _Tp& __x) { _Base::push_front(__x); this->_M_invalidate_all(); } void push_back(const _Tp& __x) { _Base::push_back(__x); this->_M_invalidate_all(); } #else template void push_front(_Args&&... __args) { _Base::push_front(std::forward<_Args>(__args)...); this->_M_invalidate_all(); } template void push_back(_Args&&... __args) { _Base::push_back(std::forward<_Args>(__args)...); this->_M_invalidate_all(); } template iterator emplace(iterator __position, _Args&&... __args) { __glibcxx_check_insert(__position); typename _Base::iterator __res = _Base::emplace(__position.base(), std::forward<_Args>(__args)...); this->_M_invalidate_all(); return iterator(__res, this); } #endif iterator insert(iterator __position, const _Tp& __x) { __glibcxx_check_insert(__position); typename _Base::iterator __res = _Base::insert(__position.base(), __x); this->_M_invalidate_all(); return iterator(__res, this); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ iterator insert(iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } #endif void insert(iterator __position, size_type __n, const _Tp& __x) { __glibcxx_check_insert(__position); _Base::insert(__position.base(), __n, __x); this->_M_invalidate_all(); } template void insert(iterator __position, _InputIterator __first, _InputIterator __last) { __glibcxx_check_insert_range(__position, __first, __last); _Base::insert(__position.base(), __first, __last); this->_M_invalidate_all(); } void pop_front() { __glibcxx_check_nonempty(); iterator __victim = begin(); __victim._M_invalidate(); _Base::pop_front(); } void pop_back() { __glibcxx_check_nonempty(); iterator __victim = end(); --__victim; __victim._M_invalidate(); _Base::pop_back(); } iterator erase(iterator __position) { __glibcxx_check_erase(__position); if (__position == begin() || __position == end()-1) { __position._M_invalidate(); return iterator(_Base::erase(__position.base()), this); } else { typename _Base::iterator __res = _Base::erase(__position.base()); this->_M_invalidate_all(); return iterator(__res, this); } } iterator erase(iterator __first, iterator __last) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container __glibcxx_check_erase_range(__first, __last); if (__first == begin() || __last == end()) { this->_M_detach_singular(); for (iterator __position = __first; __position != __last; ) { iterator __victim = __position++; __victim._M_invalidate(); } try { return iterator(_Base::erase(__first.base(), __last.base()), this); } catch(...) { this->_M_revalidate_singular(); __throw_exception_again; } } else { typename _Base::iterator __res = _Base::erase(__first.base(), __last.base()); this->_M_invalidate_all(); return iterator(__res, this); } } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ swap(deque&& __x) #else swap(deque& __x) #endif { _Base::swap(__x); this->_M_swap(__x); } void clear() { _Base::clear(); this->_M_invalidate_all(); } _Base& _M_base() { return *this; } const _Base& _M_base() const { return *this; } }; template inline bool operator==(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const deque<_Tp, _Alloc>& __lhs, const deque<_Tp, _Alloc>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template inline void swap(deque<_Tp, _Alloc>&& __lhs, deque<_Tp, _Alloc>& __rhs) { __lhs.swap(__rhs); } template inline void swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>&& __rhs) ¨" { __lhs.swap(__rhs); } #endif } // namespace __debug } // namespace std #endif // Debugging unordered_map/unordered_multimap implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/unordered_map * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_UNORDERED_MAP #define _GLIBCXX_DEBUG_UNORDERED_MAP 1 #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include #else # include #endif #include #include #define _GLIBCXX_BASE unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> #define _GLIBCXX_STD_BASE _GLIBCXX_STD_D::_GLIBCXX_BASE namespace std { namespace __debug { template, typename _Pred = std::equal_to<_Key>, typename _Alloc = std::allocator<_Key> > class unordered_map : public __gnu_debug::_Safe_association<_GLIBCXX_STD_BASE>, public __gnu_debug::_Safe_sequence<_GLIBCXX_BASE> { typedef typename _GLIBCXX_STD_BASE _Base; typedef __gnu_debug::_Safe_association<_Base> _Safe_assoc; typedef __gnu_debug::_Safe_sequence _Safe_base; public: typedef typename _Safe_assoc::size_type size_type; typedef typename _Safe_assoc::hasher hasher; typedef typename _Safe_assoc::key_equal key_equal; typedef typename _Safe_assoc::allocator_type allocator_type; explicit unordered_map(size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Safe_assoc(__n, __hf, __eql, __a) { } template unordered_map(_InputIterator __f, _InputIterator __l, size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Safe_assoc(__f, __l, __n, __hf, __eql, __a) { } unordered_map(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } unordered_map(unordered_map&& __x) : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { } unordered_map& operator=(unordered_map&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } void swap(unordered_map&& __x) { _Safe_assoc::swap(__x); _Safe_base::_M_swap(__x); } void clear() { _Base::clear(); this->_M_invalidate_all(); } private: void _M_invalidate_all() { typedef typename _Base::const_iterator _Base_const_iterator; typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal; this->_M_invalidate_if(_Not_equal(this->_M_base().end())); } }; template inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&& __y) { __x.swap(__y); } #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #define _GLIBCXX_STD_BASE _GLIBCXX_STD_D::_GLIBCXX_BASE #define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> template, typename _Pred = std::equal_to<_Key>, typename _Alloc = std::allocator<_Key> > class unordered_multimap : public __gnu_debug::_Safe_association<_GLIBCXX_STD_BASE>, public __gnu_debug::_Safe_sequence<_GLIBCXX_BASE> { typedef typename _GLIBCXX_STD_BASE _Base; typedef __gnu_debug::_Safe_association<_Base> _Safe_assoc; typedef __gnu_debug::_Safe_sequence _Safe_base; public: typedef typename _Safe_assoc::size_type size_type; typedef typename _Safe_assoc::hasher hasher; typedef typename _Safe_assoc::key_equal key_equal; typedef typename _Safe_assoc::allocator_type allocator_type; explicit unordered_multimap(size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Safe_assoc(__n, __hf, __eql, __a) { } template unordered_multimap(_InputIterator __f, _InputIterator __l, size_type __n = 10, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(), const allocator_type& __a = allocator_type()) : _Safe_assoc(__f, __l, __n, __hf, __eql, __a) { } unordered_multimap(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } unordered_multimap(unordered_multimap&& __x) : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { } unordered_multimap& operator=(unordered_multimap&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } void swap(unordered_multimap&& __x) { _Safe_assoc::swap(__x); _Safe_base::_M_swap(__x); } void clear() { _Base::clear(); this->_M_invalidate_all(); } private: void _M_invalidate_all() { typedef typename _Base::const_iterator _Base_const_iterator; typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal; this->_M_invalidate_if(_Not_equal(this->_M_base().end())); } }; template inline void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&& __y) { __x.swap(__y); } } // namespace __debug } // namespace std #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #endif // Debugging map/multimap implementation -*- C++ -*- // Copyright (C) 2003, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/map * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_MAP #define _GLIBCXX_DEBUG_MAP 1 #include #include #include #endif // Debugging set/multiset implementation -*- C++ -*- // Copyright (C) 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/set * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_SET #define _GLIBCXX_DEBUG_SET 1 #include #include #include #endif // Debugging multiset implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 2006, 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file debug/multiset.h * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_MULTISET_H #define _GLIBCXX_DEBUG_MULTISET_H 1 #include #include #include namespace std { namespace __debug { template, typename _Allocator = std::allocator<_Key> > class multiset : public _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator>, public __gnu_debug::_Safe_sequence > { typedef _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; public: // types: typedef _Key key_type; typedef _Key value_type; typedef _Compare key_compare; typedef _Compare value_compare; typedef _Allocator allocator_type; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; typedef __gnu_debug::_Safe_iterator iterator; typedef __gnu_debug::_Safe_iterator const_iterator; typedef typename _Base::size_type size_type; typedef typename _Base::difference_type difference_type; typedef typename _Base::pointer pointer; typedef typename _Base::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // 23.3.3.1 construct/copy/destroy: explicit multiset(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { } template multiset(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __comp, __a) { } multiset(const multiset& __x) : _Base(__x), _Safe_base() { } multiset(const _Base& __x) : _Base(__x), _Safe_base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ multiset(multiset&& __x) : _Base(std::forward(__x)), _Safe_base() { this->_M_swap(__x); } #endif ~multiset() { } multiset& operator=(const multiset& __x) { *static_cast<_Base*>(this) = __x; this->_M_invalidate_all(); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ multiset& operator=(multiset&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } #endif using _Base::get_allocator; // iterators: iterator begin() { return iterator(_Base::begin(), this); } const_iterator begin() const { return const_iterator(_Base::begin(), this); } iterator end() { return iterator(_Base::end(), this); } const_iterator end() const { return const_iterator(_Base::end(), this); } reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ const_iterator cbegin() const { return const_iterator(_Base::begin(), this); } const_iterator cend() const { return const_iterator(_Base::end(), this); } const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } #endif // capacity: using _Base::empty; using _Base::size; using _Base::max_size; // modifiers: iterator insert(const value_type& __x) { return iterator(_Base::insert(__x), this); } iterator insert(iterator __position, const value_type& __x) { __glibcxx_check_insert(__position); return iterator(_Base::insert(__position.base(), __x), this); } template void insert(_InputIterator __first, _InputIterator __last) { __glibcxx_check_valid_range(__first, __last); _Base::insert(__first, __last); } void erase(iterator __position) { __glibcxx_check_erase(__position); __position._M_invalidate(); _Base::erase(__position.base()); } size_type erase(const key_type& __x) { std::pair __victims = this->equal_range(__x); size_type __count = 0; while (__victims.first != __victims.second) { iterator __victim = __victims.first++; __victim._M_invalidate(); _Base::erase(__victim.base()); ++__count; } return __count; } void erase(iterator __first, iterator __last) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container __glibcxx_check_erase_range(__first, __last); while (__first != __last) this->erase(__first++); } void #ifdef __GXX_EXPERIMENTAL_CXX0X__ swap(multiset&& __x) #else swap(multiset& __x) #endif { _Base::swap(__x); this->_M_swap(__x); } void clear() { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // multiset operations: iterator find(const key_type& __x) { return iterator(_Base::find(__x), this); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator find(const key_type& __x) const { return const_iterator(_Base::find(__x), this); } using _Base::count; iterator lower_bound(const key_type& __x) { return iterator(_Base::lower_bound(__x), this); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator lower_bound(const key_type& __x) const { return const_iterator(_Base::lower_bound(__x), this); } iterator upper_bound(const key_type& __x) { return iterator(_Base::upper_bound(__x), this); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload const_iterator upper_bound(const key_type& __x) const { return const_iterator(_Base::upper_bound(__x), this); } std::pair equal_range(const key_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(iterator(__res.first, this), iterator(__res.second, this)); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 214. set::find() missing const overload std::pair equal_range(const key_type& __x) const { typedef typename _Base::const_iterator _Base_iterator; std::pair<_Base_iterator, _Base_iterator> __res = _Base::equal_range(__x); return std::make_pair(const_iterator(__res.first, this), const_iterator(__res.second, this)); } _Base& _M_base() { return *this; } const _Base& _M_base() const { return *this; } private: void _M_invalidate_all() { typedef typename _Base::const_iterator _Base_const_iterator; typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal; this->_M_invalidate_if(_Not_equal(_M_base().end())); } }; template inline bool operator==(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const multiset<_Key, _Compare, _Allocator>& __lhs, const multiset<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template void swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y) { return __x.swap(__y); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template void swap(multiset<_Key, _Compare, _Allocator>&& __x, multiset<_Key, _Compare, _Allocator>& __y) { return