"rhs")); return __lhs.base() - __rhs.base(); } template inline _Safe_iterator<_Iterator, _Sequence> operator+(typename _Safe_iterator<_Iterator,_Sequence>::difference_type __n, const _Safe_iterator<_Iterator, _Sequence>& __i) { return __i + __n; } } // namespace __gnu_debug #ifndef _GLIBCXX_EXPORT_TEMPLATE # include #endif #endif // Safe sequence implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 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/safe_sequence.h * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H #define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1 #include #include #include #include namespace __gnu_debug { template class _Safe_iterator; /** A simple function object that returns true if the passed-in * value is not equal to the stored value. It saves typing over * using both bind1st and not_equal. */ template class _Not_equal_to { _Type __value; public: explicit _Not_equal_to(const _Type& __v) : __value(__v) { } bool operator()(const _Type& __x) const { return __value != __x; } }; /** A function object that returns true when the given random access iterator is at least @c n steps away from the given iterator. */ template class _After_nth_from { typedef typename std::iterator_traits<_Iterator>::difference_type difference_type; _Iterator _M_base; difference_type _M_n; public: _After_nth_from(const difference_type& __n, const _Iterator& __base) : _M_base(__base), _M_n(__n) { } bool operator()(const _Iterator& __x) const { return __x - _M_base >= _M_n; } }; /** * @brief Base class for constructing a "safe" sequence type that * tracks iterators that reference it. * * The class template %_Safe_sequence simplifies the construction of * "safe" sequences that track the iterators that reference the * sequence, so that the iterators are notified of changes in the * sequence that may affect their operation, e.g., if the container * invalidates its iterators or is destructed. This class template * may only be used by deriving from it and passing the name of the * derived class as its template parameter via the curiously * recurring template pattern. The derived class must have @c * iterator and @const_iterator types that are instantiations of * class template _Safe_iterator for this sequence. Iterators will * then be tracked automatically. */ template class _Safe_sequence : public _Safe_sequence_base { public: /** Invalidates all iterators @c x that reference this sequence, are not singular, and for which @c pred(x) returns @c true. The user of this routine should be careful not to make copies of the iterators passed to @p pred, as the copies may interfere with the invalidation. */ template void _M_invalidate_if(_Predicate __pred); /** Transfers all iterators that reference this memory location to this sequence from whatever sequence they are attached to. */ template void _M_transfer_iter(const _Safe_iterator<_Iterator, _Sequence>& __x); }; template template void _Safe_sequence<_Sequence>:: _M_invalidate_if(_Predicate __pred) { typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); for (_Safe_iterator_base* __iter = _M_iterators; __iter;) { iterator* __victim = static_cast(__iter); __iter = __iter->_M_next; if (!__victim->_M_singular()) { if (__pred(__victim->base())) __victim->_M_invalidate_single(); } } for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;) { const_iterator* __victim = static_cast(__iter2); __iter2 = __iter2->_M_next; if (!__victim->_M_singular()) { if (__pred(__victim->base())) __victim->_M_invalidate_single(); } } } template template void _Safe_sequence<_Sequence>:: _M_transfer_iter(const _Safe_iterator<_Iterator, _Sequence>& __x) { _Safe_sequence_base* __from = __x._M_sequence; if (!__from) return; typedef typename _Sequence::iterator iterator; typedef typename _Sequence::const_iterator const_iterator; __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); for (_Safe_iterator_base* __iter = __from->_M_iterators; __iter;) { iterator* __victim = static_cast(__iter); __iter = __iter->_M_next; if (!__victim->_M_singular() && __victim->base() == __x.base()) __victim->_M_attach_single(static_cast<_Sequence*>(this)); } for (_Safe_iterator_base* __iter2 = __from->_M_const_iterators; __iter2;) { const_iterator* __victim = static_cast(__iter2); __iter2 = __iter2->_M_next; if (!__victim->_M_singular() && __victim->base() == __x.base()) __victim->_M_attach_single(static_cast<_Sequence*>(this)); } } } // namespace __gnu_debug #endif // Debug-mode error formatting 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/formatter.h * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_FORMATTER_H #define _GLIBCXX_DEBUG_FORMATTER_H 1 #include #include namespace __gnu_debug { using std::type_info; /** Determine if the two types are the same. */ template struct __is_same { static const bool value = false; }; template struct __is_same<_Type, _Type> { static const bool value = true; }; template struct __truth { }; class _Safe_sequence_base; template class _Safe_iterator; template class _Safe_sequence; enum _Debug_msg_id { // General checks __msg_valid_range, __msg_insert_singular, __msg_insert_different, __msg_erase_bad, __msg_erase_different, __msg_subscript_oob, __msg_empty, __msg_unpartitioned, __msg_unpartitioned_pred, __msg_unsorted, __msg_unsorted_pred, __msg_not_heap, __msg_not_heap_pred, // std::bitset checks __msg_bad_bitset_write, __msg_bad_bitset_read, __msg_bad_bitset_flip, // std::list checks __msg_self_splice, __msg_splice_alloc, __msg_splice_bad, __msg_splice_other, __msg_splice_overlap, // iterator checks __msg_init_singular, __msg_init_copy_singular, __msg_init_const_singular, __msg_copy_singular, __msg_bad_deref, __msg_bad_inc, __msg_bad_dec, __msg_iter_subscript_oob, __msg_advance_oob, __msg_retreat_oob, __msg_iter_compare_bad, __msg_compare_different, __msg_iter_order_bad, __msg_order_different, __msg_distance_bad, __msg_distance_different, // istream_iterator __msg_deref_istream, __msg_inc_istream, // ostream_iterator __msg_output_ostream, // istreambuf_iterator __msg_deref_istreambuf, __msg_inc_istreambuf }; class _Error_formatter { /// Whether an iterator is constant, mutable, or unknown enum _Constness { __unknown_constness, __const_iterator, __mutable_iterator, __last_constness }; // The state of the iterator (fine-grained), if we know it. enum _Iterator_state { __unknown_state, __singular, // singular, may still be attached to a sequence __begin, // dereferenceable, and at the beginning __middle, // dereferenceable, not at the beginning __end, // past-the-end, may be at beginning if sequence empty __last_state }; // Tags denoting the type of parameter for construction struct _Is_iterator { }; struct _Is_sequence { }; // A parameter that may be referenced by an error message struct _Parameter { enum { __unused_param, __iterator, __sequence, __integer, __string } _M_kind; union { // When _M_kind == __iterator struct { const char* _M_name; const void* _M_address; const type_info* _M_type; _Constness _M_constness; _Iterator_state _M_state; const void* _M_sequence; const type_info* _M_seq_type; } _M_iterator; // When _M_kind == __sequence struct { const char* _M_name; const void* _M_address; const type_info* _M_type; } _M_sequence; // When _M_kind == __integer struct { const char* _M_name; long _M_value; } _M_integer; // When _M_kind == __string struct { const char* _M_name; const char* _M_value; } _M_string; } _M_variant; _Parameter() : _M_kind(__unused_param), _M_variant() { } _Parameter(long __value, const char* __name) : _M_kind(__integer), _M_variant() { _M_variant._M_integer._M_name = __name; _M_variant._M_integer._M_value = __value; } _Parameter(const char* __value, const char* __name) : _M_kind(__string), _M_variant() { _M_variant._M_string._M_name = __name; _M_variant._M_string._M_value = __value; } template _Parameter(const _Safe_iterator<_Iterator, _Sequence>& __it, const char* __name, _Is_iterator) : _M_kind(__iterator), _M_variant() { _M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_type = &typeid(__it); _M_variant._M_iterator._M_constness = __is_same<_Safe_iterator<_Iterator, _Sequence>, typename _Sequence::iterator>:: value? __mutable_iterator : __const_iterator; _M_variant._M_iterator._M_sequence = __it._M_get_sequence(); _M_variant._M_iterator._M_seq_type = &typeid(_Sequence); if (__it._M_singular()) _M_variant._M_iterator._M_state = __singular; else { bool __is_begin = __it._M_is_begin(); bool __is_end = __it._M_is_end(); if (__is_end) _M_variant._M_iterator._M_state = __end; else if (__is_begin) _M_variant._M_iterator._M_state = __begin; else _M_variant._M_iterator._M_state = __middle; } } template _Parameter(const _Type*& __it, const char* __name, _Is_iterator) : _M_kind(__iterator), _M_variant() { _M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_type = &typeid(__it); _M_variant._M_iterator._M_constness = __mutable_iterator; _M_variant._M_iterator._M_state = __it? __unknown_state : __singular; _M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_seq_type = 0; } template _Parameter(_Type*& __it, const char* __name, _Is_iterator) : _M_kind(__iterator), _M_variant() { _M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_type = &typeid(__it); _M_variant._M_iterator._M_constness = __const_iterator; _M_variant._M_iterator._M_state = __it? __unknown_state : __singular; _M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_seq_type = 0; } template _Parameter(const _Iterator& __it, const char* __name, _Is_iterator) : _M_kind(__iterator), _M_variant() { _M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_type = &typeid(__it); _M_variant._M_iterator._M_constness = __unknown_constness; _M_variant._M_iterator._M_state = __gnu_debug::__check_singular(__it)? __singular : __unknown_state; _M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_seq_type = 0; } template _Parameter(const _Safe_sequence<_Sequence>& __seq, const char* __name, _Is_sequence) : _M_kind(__sequence), _M_variant() { _M_variant._M_sequence._M_name = __name; _M_variant._M_sequence._M_address = static_cast(&__seq); _M_variant._M_sequence._M_type = &typeid(_Sequence); } template _Parameter(const _Sequence& __seq, const char* __name, _Is_sequence) : _M_kind(__sequence), _M_variant() { _M_variant._M_sequence._M_name = __name; _M_variant._M_sequence._M_address = &__seq; _M_variant._M_sequence._M_type = &typeid(_Sequence); } void _M_print_field(const _Error_formatter* __formatter, const char* __name) const; void _M_print_description(const _Error_formatter* __formatter) const; }; friend struct _Parameter; public: template const _Error_formatter& _M_iterator(const _Iterator& __it, const char* __name = 0) const { if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__it, __name, _Is_iterator()); return *this; } const _Error_formatter& _M_integer(long __value, const char* __name = 0) const { if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); return *this; } const _Error_formatter& _M_string(const char* __value, const char* __name = 0) const { if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); return *this; } template const _Error_formatter& _M_sequence(const _Sequence& __seq, const char* __name = 0) const { if (_M_num_parameters < size_t(__max_parameters)) _M_parameters[_M_num_parameters++] = _Parameter(__seq, __name, _Is_sequence()); return *this; } const _Error_formatter& _M_message(const char* __text) const { _M_text = __text; return *this; } const _Error_formatter& _M_message(_Debug_msg_id __id) const; void _M_error() const; private: _Error_formatter(const char* __file, size_t __line) : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0), _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false) { _M_get_max_length(); } template void _M_format_word(char*, int, const char*, _Tp) const; void _M_print_word(const char* __word) const; void _M_print_string(const char* __string) const; void _M_get_max_length() const; enum { __max_parameters = 9 }; const char* _M_file; size_t _M_line; mutable _Parameter _M_parameters[__max_parameters]; mutable size_t _M_num_parameters; mutable const char* _M_text; mutable size_t _M_max_length; enum { _M_indent = 4 } ; mutable size_t _M_column; mutable bool _M_first_line; mutable bool _M_wordwrap; public: static _Error_formatter _M_at(const char* __file, size_t __line) { return _Error_formatter(__file, __line); } }; } // namespace __gnu_debug #endif // Debugging set 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/set.h * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_SET_H #define _GLIBCXX_DEBUG_SET_H 1 #include #include #include namespace std { namespace __debug { template, typename _Allocator = std::allocator<_Key> > class set : public _GLIBCXX_STD_D::set<_Key,_Compare,_Allocator>, public __gnu_debug::_Safe_sequence > { typedef _GLIBCXX_STD_D::set<_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 set(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { } template set(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __comp, __a) { } set(const set& __x) : _Base(__x), _Safe_base() { } set(const _Base& __x) : _Base(__x), _Safe_base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ set(set&& __x) : _Base(std::forward(__x)), _Safe_base() { this->_M_swap(__x); } #endif ~set() { } set& operator=(const set& __x) { *static_cast<_Base*>(this) = __x; this->_M_invalidate_all(); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ set& operator=(set&& __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: std::pair insert(const value_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, bool> __res = _Base::insert(__x); return std::pair(iterator(__res.first, this), __res.second); } 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) { iterator __victim = find(__x); if (__victim == end()) return 0; else { __victim._M_invalidate(); _Base::erase(__victim.base()); return 1; } } 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(set&& __x) #else swap(set& __x) #endif { _Base::swap(__x); this->_M_swap(__x); } void clear() { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // set 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 set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const set<_Key, _Compare, _Allocator>& __lhs, const set<_Key, _Compare, _Allocator>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) { return __x.swap(__y); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template void swap(set<_Key, _Compare, _Allocator>&& __x, set<_Key, _Compare, _Allocator>& __y) { return __x.swap(__y); } template void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>&& __y) { return __x.swap(__y); } #endif } // namespace __debug } // namespace std #endif // Debugging map 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/map.h * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_MAP_H #define _GLIBCXX_DEBUG_MAP_H 1 #include #include #include namespace std { namespace __debug { template, typename _Allocator = std::allocator > > class map : public _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator>, public __gnu_debug::_Safe_sequence > { typedef _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator> _Base; typedef __gnu_debug::_Safe_sequence _Safe_base; public: // types: typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair value_type; typedef _Compare key_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; using _Base::value_compare; // 23.3.1.1 construct/copy/destroy: explicit map(const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__comp, __a) { } template map(_InputIterator __first, _InputIterator __last, const _Compare& __comp = _Compare(), const _Allocator& __a = _Allocator()) : _Base(__gnu_debug::__check_valid_range(__first, __last), __last, __comp, __a), _Safe_base() { } map(const map& __x) : _Base(__x), _Safe_base() { } map(const _Base& __x) : _Base(__x), _Safe_base() { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ map(map&& __x) : _Base(std::forward(__x)), _Safe_base() { this->_M_swap(__x); } #endif ~map() { } map& operator=(const map& __x) { *static_cast<_Base*>(this) = __x; this->_M_invalidate_all(); return *this; } #ifdef __GXX_EXPERIMENTAL_CXX0X__ map& operator=(map&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS // 133. map missing get_allocator() 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; // 23.3.1.2 element access: using _Base::operator[]; // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 464. Suggestion for new member functions in standard containers. using _Base::at; // modifiers: std::pair insert(const value_type& __x) { typedef typename _Base::iterator _Base_iterator; std::pair<_Base_iterator, bool> __res = _Base::insert(__x); return std::pair(iterator(__res.first, this), __res.second); } 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) { iterator __victim = find(__x); if (__victim == end()) return 0; else { __victim._M_invalidate(); _Base::erase(__victim.base()); return 1; } } 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(map&& __x) #else swap(map& __x) #endif { _Base::swap(__x); this->_M_swap(__x); } void clear() { this->erase(begin(), end()); } // observers: using _Base::key_comp; using _Base::value_comp; // 23.3.1.3 map operations: iterator find(const key_type& __x) { return iterator(_Base::find(__x), this); } 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); } 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); } 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)); } std::pair equal_range(const key_type& __x) const { typedef typename _Base::const_iterator _Base_const_iterator; std::pair<_Base_const_iterator, _Base_const_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 map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() == __rhs._M_base(); } template inline bool operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() != __rhs._M_base(); } template inline bool operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() < __rhs._M_base(); } template inline bool operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() <= __rhs._M_base(); } template inline bool operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() >= __rhs._M_base(); } template inline bool operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, const map<_Key, _Tp, _Compare, _Allocator>& __rhs) { return __lhs._M_base() > __rhs._M_base(); } template inline void swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __lhs.swap(__rhs); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ template inline void swap(map<_Key, _Tp, _Compare, _Allocator>&& __lhs, map<_Key, _Tp, _Compare, _Allocator>& __rhs) { __lhs.swap(__rhs); } template inline void swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, map<_Key, _Tp, _Compare, _Allocator>&& __rhs) { __lhs.swap(__rhs); } #endif } // namespace __debug } // namespace std #endif // Debugging unordered_set/unordered_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/unordered_set * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_UNORDERED_SET #define _GLIBCXX_DEBUG_UNORDERED_SET 1 #ifdef __GXX_EXPERIMENTAL_CXX0X__ # include #else # include #endif #include #include #define _GLIBCXX_BASE unordered_set<_Value, _Hash, _Pred, _Alloc> #define _GLIBCXX_STD_BASE _GLIBCXX_STD_D::_GLIBCXX_BASE namespace std { namespace __debug { template, typename _Pred = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class unordered_set : 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_set(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_set(_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_set(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } unordered_set(unordered_set&& __x) : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { } unordered_set& operator=(unordered_set&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } void swap(unordered_set&& __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_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x, unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _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_multiset<_Value, _Hash, _Pred, _Alloc> template, typename _Pred = std::equal_to<_Value>, typename _Alloc = std::allocator<_Value> > class unordered_multiset : 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_multiset(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_multiset(_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_multiset(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } unordered_multiset(unordered_multiset&& __x) : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { } unordered_multiset& operator=(unordered_multiset&& __x) { // NB: DR 675. clear(); swap(__x); return *this; } void swap(unordered_multiset&& __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_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } template inline void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y) { __x.swap(__y); } } // namespace __debug } // namespace std #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #endif // Debugging support implementation -*- C++ -*- // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 // 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/macros.h * This file is a GNU debug extension to the Standard C++ Library. */ #ifndef _GLIBCXX_DEBUG_MACROS_H #define _GLIBCXX_DEBUG_MACROS_H 1 /** * Macros used by the implementation to verify certain * properties. These macros may only be used directly by the debug * wrappers. Note that these are macros (instead of the more obviously * "correct" choice of making them functions) because we need line and * file information at the call site, to minimize the distance between * the user error and where the error is reported. * */ #define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ do \ { \ if (! (_Condition)) \ __gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \ ._ErrorMessage._M_error(); \ } while (false) // Verify that [_First, _Last) forms a valid iterator range. #define __glibcxx_check_valid_range(_First,_Last) \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ _M_message(__gnu_debug::__msg_valid_range) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last)) /** Verify that we can insert into *this with the iterator _Position. * Insertion into a container at a specific position requires that * the iterator be nonsingular (i.e., either dereferenceable or * past-the-end) and that it reference the sequence we are inserting * into. Note that this macro is only valid when the container is a * _Safe_sequence and the iterator is a _Safe_iterator. */ #define __glibcxx_check_insert(_Position) \ _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ _M_message(__gnu_debug::__msg_insert_singular) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)); \ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ _M_message(__gnu_debug::__msg_insert_different) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)) /** Verify that we can insert the values in the iterator range * [_First, _Last) into *this with the iterator _Position. Insertion * into a container at a specific position requires that the iterator * be nonsingular (i.e., either dereferenceable or past-the-end), * that it reference the sequence we are inserting into, and that the * iterator range [_First, Last) is a valid (possibly empty) * range. Note that this macro is only valid when the container is a * _Safe_sequence and the iterator is a _Safe_iterator. * * @tbd We would like to be able to check for noninterference of * _Position and the range [_First, _Last), but that can't (in * general) be done. */ #define __glibcxx_check_insert_range(_Position,_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ _M_message(__gnu_debug::__msg_insert_singular) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)); \ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ _M_message(__gnu_debug::__msg_insert_different) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)) /** Verify that we can erase the element referenced by the iterator * _Position. We can erase the element if the _Position iterator is * dereferenceable and references this sequence. */ #define __glibcxx_check_erase(_Position) \ _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ _M_message(__gnu_debug::__msg_erase_bad) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)); \ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ _M_message(__gnu_debug::__msg_erase_different) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)) /** Verify that we can erase the elements in the iterator range * [_First, _Last). We can erase the elements if [_First, _Last) is a * valid iterator range within this sequence. */ #define __glibcxx_check_erase_range(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ _M_message(__gnu_debug::__msg_erase_different) \ ._M_sequence(*this, "this") \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last)) // Verify that the subscript _N is less than the container's size. #define __glibcxx_check_subscript(_N) \ _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ _M_message(__gnu_debug::__msg_subscript_oob) \ ._M_sequence(*this, "this") \ ._M_integer(_N, #_N) \ ._M_integer(this->size(), "size")) // Verify that the container is nonempty #define __glibcxx_check_nonempty() \ _GLIBCXX_DEBUG_VERIFY(! this->empty(), \ _M_message(__gnu_debug::__msg_empty) \ ._M_sequence(*this, "this")) // Verify that the iterator range [_First, _Last) is sorted #define __glibcxx_check_sorted(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ _M_message(__gnu_debug::__msg_unsorted) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last)) /** Verify that the iterator range [_First, _Last) is sorted by the predicate _Pred. */ #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ _M_message(__gnu_debug::__msg_unsorted_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ ._M_string(#_Pred)) // Special variant for std::merge, std::includes, std::set_* #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \ __glibcxx_check_valid_range(_First1,_Last1); \ _GLIBCXX_DEBUG_VERIFY( \ __gnu_debug::__check_sorted_set(_First1, _Last1, _First2), \ _M_message(__gnu_debug::__msg_unsorted) \ ._M_iterator(_First1, #_First1) \ ._M_iterator(_Last1, #_Last1)) // Likewise with a _Pred. #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ __glibcxx_check_valid_range(_First1,_Last1); \ _GLIBCXX_DEBUG_VERIFY( \ __gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred), \ _M_message(__gnu_debug::__msg_unsorted_pred) \ ._M_iterator(_First1, #_First1) \ ._M_iterator(_Last1, #_Last1) \ ._M_string(#_Pred)) /** Verify that the iterator range [_First, _Last) is partitioned w.r.t. the value _Value. */ #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ _Value), \ _M_message(__gnu_debug::__msg_unpartitioned) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ ._M_string(#_Value)) #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ _Value), \ _M_message(__gnu_debug::__msg_unpartitioned) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ ._M_string(#_Value)) /** Verify that the iterator range [_First, _Last) is partitioned w.r.t. the value _Value and predicate _Pred. */ #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ _Value, _Pred), \ _M_message(__gnu_debug::__msg_unpartitioned_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ ._M_string(#_Pred) \ ._M_string(#_Value)) /** Verify that the iterator range [_First, _Last) is partitioned w.r.t. the value _Value and predicate _Pred. */ #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ _Value, _Pred), \ _M_message(__gnu_debug::__msg_unpartitioned_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ ._M_string(#_Pred) \ ._M_string(#_Value)) // Verify that the iterator range [_First, _Last) is a heap #define __glibcxx_check_heap(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \ _M_message(__gnu_debug::__msg_not_heap) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last)) /** Verify that the iterator range [_First, _Last) is a heap w.r.t. the predicate _Pred. */ #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \ _M_message(__gnu_debug::__msg_not_heap_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ ._M_string(#_Pred)) #ifdef _GLIBCXX_DEBUG_PEDANTIC # define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0) # define __glibcxx_check_string_len(_String,_Len) \ _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0) #else # define __glibcxx_check_string(_String) # define __glibcxx_check_string_len(_String,_Len) #endif #endif