diff options
Diffstat (limited to 'libstdc++-v3/include/debug')
| -rw-r--r-- | libstdc++-v3/include/debug/debug.h | 6 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/hash_map | 42 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/hash_map.h | 284 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/hash_multimap.h | 268 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/hash_multiset.h | 243 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/hash_set | 42 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/safe_association.h (renamed from libstdc++-v3/include/debug/hash_set.h) | 211 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/unordered_map | 199 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/unordered_set | 192 |
9 files changed, 479 insertions, 1008 deletions
diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index 46e4b6bf09e..32f96a37bed 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -49,15 +49,9 @@ namespace std namespace __debug { } } -namespace __gnu_cxx -{ - namespace __debug { }; -} - namespace __gnu_debug { using namespace std::__debug; - using namespace __gnu_cxx::__debug; } #ifndef _GLIBCXX_DEBUG diff --git a/libstdc++-v3/include/debug/hash_map b/libstdc++-v3/include/debug/hash_map deleted file mode 100644 index f44586b0ab6..00000000000 --- a/libstdc++-v3/include/debug/hash_map +++ /dev/null @@ -1,42 +0,0 @@ -// Debugging hash_map/hash_multimap implementation -*- C++ -*- - -// Copyright (C) 2003, 2005 -// 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/hash_map - * This file is a GNU debug extension to the Standard C++ Library. - */ - -#ifndef _GLIBCXX_DEBUG_HASH_MAP -#define _GLIBCXX_DEBUG_HASH_MAP 1 - -#include <ext/hash_map> -#include <debug/hash_map.h> -#include <debug/hash_multimap.h> - -#endif diff --git a/libstdc++-v3/include/debug/hash_map.h b/libstdc++-v3/include/debug/hash_map.h deleted file mode 100644 index aeac90b8a13..00000000000 --- a/libstdc++-v3/include/debug/hash_map.h +++ /dev/null @@ -1,284 +0,0 @@ -// Debugging hash_map implementation -*- C++ -*- - -// Copyright (C) 2003, 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/hash_map.h - * This file is a GNU debug extension to the Standard C++ Library. - */ - -#ifndef _GLIBCXX_DEBUG_HASH_MAP_H -#define _GLIBCXX_DEBUG_HASH_MAP_H 1 - -#include <debug/safe_sequence.h> -#include <debug/safe_iterator.h> - -namespace __gnu_cxx -{ -namespace __debug -{ - template<typename _Value, typename _Tp, - typename _HashFcn = __gnu_cxx::hash<_Value>, - typename _EqualKey = std::equal_to<_Value>, - typename _Alloc = std::allocator<_Value> > - class hash_map - : public _GLIBCXX_EXT_D::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>, - public __gnu_debug::_Safe_sequence<hash_map<_Value, _Tp, _HashFcn, - _EqualKey, _Alloc> > - { - typedef _GLIBCXX_EXT_D::hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc> - _Base; - typedef __gnu_debug::_Safe_sequence<hash_map> _Safe_base; - - public: - typedef typename _Base::key_type key_type; - typedef typename _Base::data_type data_type; - typedef typename _Base::mapped_type mapped_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - 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 typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - - typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, hash_map> - iterator; - typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator, - hash_map> - const_iterator; - - typedef typename _Base::allocator_type allocator_type; - - using _Base::hash_funct; - using _Base::key_eq; - using _Base::get_allocator; - - hash_map() { } - - explicit hash_map(size_type __n) : _Base(__n) { } - - hash_map(size_type __n, const hasher& __hf) : _Base(__n, __hf) { } - - hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__n, __hf, __eql, __a) { } - - template<typename _InputIterator> - hash_map(_InputIterator __f, _InputIterator __l) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { } - - template<typename _InputIterator> - hash_map(_InputIterator __f, _InputIterator __l, size_type __n) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { } - - template<typename _InputIterator> - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) { } - - template<typename _InputIterator> - hash_map(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf, - __eql, __a) { } - - hash_map(const _Base& __x) : _Base(__x), _Safe_base() { } - - using _Base::size; - using _Base::max_size; - using _Base::empty; - - void - swap(hash_map& __x) - { - _Base::swap(__x); - this->_M_swap(__x); - } - - iterator - begin() { return iterator(_Base::begin(), this); } - - iterator - end() { return iterator(_Base::end(), this); } - - const_iterator - begin() const - { return const_iterator(_Base::begin(), this); } - - const_iterator - end() const - { return const_iterator(_Base::end(), this); } - - std::pair<iterator, bool> - insert(const value_type& __obj) - { - std::pair<typename _Base::iterator, bool> __res = _Base::insert(__obj); - return std::make_pair(iterator(__res.first, this), __res.second); - } - - void - insert(const value_type* __first, const value_type* __last) - { - __glibcxx_check_valid_range(__first, __last); - _Base::insert(__first, __last); - } - - template<typename _InputIterator> - void - insert(_InputIterator __first, _InputIterator __last) - { - __glibcxx_check_valid_range(__first, __last); - _Base::insert(__first.base(), __last.base()); - } - - - std::pair<iterator, bool> - insert_noresize(const value_type& __obj) - { - std::pair<typename _Base::iterator, bool> __res = - _Base::insert_noresize(__obj); - return std::make_pair(iterator(__res.first, this), __res.second); - } - - iterator - find(const key_type& __key) - { return iterator(_Base::find(__key), this); } - - const_iterator - find(const key_type& __key) const - { return const_iterator(_Base::find(__key), this); } - - using _Base::operator[]; - using _Base::count; - - std::pair<iterator, iterator> - equal_range(const key_type& __key) - { - typedef typename _Base::iterator _Base_iterator; - std::pair<_Base_iterator, _Base_iterator> __res = - _Base::equal_range(__key); - return std::make_pair(iterator(__res.first, this), - iterator(__res.second, this)); - } - - std::pair<const_iterator, const_iterator> - equal_range(const key_type& __key) const - { - typedef typename _Base::const_iterator _Base_iterator; - std::pair<_Base_iterator, _Base_iterator> __res = - _Base::equal_range(__key); - return std::make_pair(const_iterator(__res.first, this), - const_iterator(__res.second, this)); - } - - size_type - erase(const key_type& __key) - { - iterator __victim(_Base::find(__key), this); - if (__victim != end()) - return this->erase(__victim), 1; - else - return 0; - } - - void - erase(iterator __it) - { - __glibcxx_check_erase(__it); - __it._M_invalidate(); - _Base::erase(__it.base()); - } - - void - erase(iterator __first, iterator __last) - { - __glibcxx_check_erase_range(__first, __last); - for (iterator __tmp = __first; __tmp != __last;) - { - iterator __victim = __tmp++; - __victim._M_invalidate(); - } - _Base::erase(__first.base(), __last.base()); - } - - void - clear() - { - _Base::clear(); - this->_M_invalidate_all(); - } - - using _Base::resize; - using _Base::bucket_count; - using _Base::max_bucket_count; - using _Base::elems_in_bucket; - - _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<typename _Value, typename _Tp, typename _HashFcn, - typename _EqualKey, typename _Alloc> - inline bool - operator==(const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, - const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) - { return __x._M_base() == __y._M_base(); } - - template<typename _Value, typename _Tp, typename _HashFcn, - typename _EqualKey, typename _Alloc> - inline bool - operator!=(const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, - const hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) - { return __x._M_base() != __y._M_base(); } - - template<typename _Value, typename _Tp, typename _HashFcn, - typename _EqualKey, typename _Alloc> - inline void - swap(hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, - hash_map<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) - { __x.swap(__y); } -} // namespace __debug -} // namespace __gnu_cxx - -#endif diff --git a/libstdc++-v3/include/debug/hash_multimap.h b/libstdc++-v3/include/debug/hash_multimap.h deleted file mode 100644 index 985fbc83030..00000000000 --- a/libstdc++-v3/include/debug/hash_multimap.h +++ /dev/null @@ -1,268 +0,0 @@ -// Debugging hash_multimap implementation -*- C++ -*- - -// Copyright (C) 2003, 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/hash_multimap.h - * This file is a GNU debug extension to the Standard C++ Library. - */ - -#ifndef _GLIBCXX_DEBUG_HASH_MULTIMAP_H -#define _GLIBCXX_DEBUG_HASH_MULTIMAP_H 1 - -#include <debug/safe_sequence.h> -#include <debug/safe_iterator.h> - -namespace __gnu_cxx -{ -namespace __debug -{ - template<typename _Value, typename _Tp, - typename _HashFcn = __gnu_cxx::hash<_Value>, - typename _EqualKey = std::equal_to<_Value>, - typename _Alloc = std::allocator<_Value> > - class hash_multimap - : public _GLIBCXX_EXT_D::hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>, - public __gnu_debug::_Safe_sequence<hash_multimap<_Value, _Tp, _HashFcn, - _EqualKey, _Alloc> > - { - typedef _GLIBCXX_EXT_D::hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc> - _Base; - typedef __gnu_debug::_Safe_sequence<hash_multimap> _Safe_base; - - public: - typedef typename _Base::key_type key_type; - typedef typename _Base::data_type data_type; - typedef typename _Base::mapped_type mapped_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - 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 typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - - typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, - hash_multimap> iterator; - typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator, - hash_multimap> const_iterator; - - typedef typename _Base::allocator_type allocator_type; - - using _Base::hash_funct; - using _Base::key_eq; - using _Base::get_allocator; - - hash_multimap() { } - - explicit hash_multimap(size_type __n) : _Base(__n) { } - - hash_multimap(size_type __n, const hasher& __hf) : _Base(__n, __hf) { } - - hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__n, __hf, __eql, __a) { } - - template<typename _InputIterator> - hash_multimap(_InputIterator __f, _InputIterator __l) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { } - - template<typename _InputIterator> - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { } - - template<typename _InputIterator> - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) { } - - template<typename _InputIterator> - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf, - __eql, __a) { } - - using _Base::size; - using _Base::max_size; - using _Base::empty; - - void - swap(hash_multimap& __x) - { - _Base::swap(__x); - this->_M_swap(__x); - } - - iterator - begin() { return iterator(_Base::begin(), this); } - - iterator - end() { return iterator(_Base::end(), this); } - - const_iterator - begin() const - { return const_iterator(_Base::begin(), this); } - - const_iterator - end() const - { return const_iterator(_Base::end(), this); } - - iterator - insert(const value_type& __obj) - { return iterator(_Base::insert(__obj), this); } - - template <typename _InputIterator> - void - insert(_InputIterator __first, _InputIterator __last) - { - __glibcxx_check_valid_range(__first, __last); - _Base::insert(__first.base(), __last.base()); - } - - iterator - insert_noresize(const value_type& __obj) - { return iterator(_Base::insert_noresize(__obj), this); } - - iterator - find(const key_type& __key) - { return iterator(_Base::find(__key), this); } - - const_iterator - find(const key_type& __key) const - { return const_iterator(_Base::find(__key), this); } - - using _Base::count; - - std::pair<iterator, iterator> - equal_range(const key_type& __key) - { - typedef typename _Base::iterator _Base_iterator; - std::pair<_Base_iterator, _Base_iterator> __res = - _Base::equal_range(__key); - return std::make_pair(iterator(__res.first, this), - iterator(__res.second, this)); - } - - std::pair<const_iterator, const_iterator> - equal_range(const key_type& __key) const - { - typedef typename _Base::const_iterator _Base_iterator; - std::pair<_Base_iterator, _Base_iterator> __res = - _Base::equal_range(__key); - return std::make_pair(const_iterator(__res.first, this), - const_iterator(__res.second, this)); - } - - size_type - erase(const key_type& __key) - { - std::pair<iterator, iterator> __victims = this->equal_range(__key); - std::size_t __num_victims = 0; - while (__victims.first != __victims.second) - { - this->erase(__victims.first++); - ++__num_victims; - } - return __num_victims; - } - - void - erase(iterator __it) - { - __glibcxx_check_erase(__it); - __it._M_invalidate(); - _Base::erase(__it.base()); - } - - void - erase(iterator __first, iterator __last) - { - __glibcxx_check_erase_range(__first, __last); - for (iterator __tmp = __first; __tmp != __last;) - { - iterator __victim = __tmp++; - __victim._M_invalidate(); - } - _Base::erase(__first.base(), __last.base()); - } - - void - clear() - { - _Base::clear(); - this->_M_invalidate_all(); - } - - using _Base::resize; - using _Base::bucket_count; - using _Base::max_bucket_count; - using _Base::elems_in_bucket; - - _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<typename _Value, typename _Tp, typename _HashFcn, - typename _EqualKey, typename _Alloc> - inline bool - operator==(const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __x, - const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __y) - { return __x._M_base() == __y._M_base(); } - - template<typename _Value, typename _Tp, typename _HashFcn, - typename _EqualKey, typename _Alloc> - inline bool - operator!=(const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __x, - const hash_multimap<_Value,_Tp,_HashFcn,_EqualKey,_Alloc>& __y) - { return __x._M_base() != __y._M_base(); } - - template<typename _Value, typename _Tp, typename _HashFcn, - typename _EqualKey, typename _Alloc> - inline void - swap(hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __x, - hash_multimap<_Value, _Tp, _HashFcn, _EqualKey, _Alloc>& __y) - { __x.swap(__y); } -} // namespace __debug -} // namespace __gnu_cxx - -#endif diff --git a/libstdc++-v3/include/debug/hash_multiset.h b/libstdc++-v3/include/debug/hash_multiset.h deleted file mode 100644 index 11efb5b6846..00000000000 --- a/libstdc++-v3/include/debug/hash_multiset.h +++ /dev/null @@ -1,243 +0,0 @@ -// Debugging hash_multiset implementation -*- C++ -*- - -// Copyright (C) 2003, 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/hash_multiset.h - * This file is a GNU debug extension to the Standard C++ Library. - */ - -#ifndef _GLIBCXX_DEBUG_HASH_MULTISET_H -#define _GLIBCXX_DEBUG_HASH_MULTISET_H 1 - -#include <debug/safe_sequence.h> -#include <debug/safe_iterator.h> - -namespace __gnu_cxx -{ -namespace __debug -{ - template<typename _Value, - typename _HashFcn = __gnu_cxx::hash<_Value>, - typename _EqualKey = std::equal_to<_Value>, - typename _Alloc = std::allocator<_Value> > - class hash_multiset - : public _GLIBCXX_EXT_D::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>, - public __gnu_debug::_Safe_sequence<hash_multiset<_Value, _HashFcn, - _EqualKey, _Alloc> > - { - typedef _GLIBCXX_EXT_D:: hash_multiset<_Value,_HashFcn, _EqualKey,_Alloc> - _Base; - typedef __gnu_debug::_Safe_sequence<hash_multiset> _Safe_base; - - public: - typedef typename _Base::key_type key_type; - typedef typename _Base::value_type value_type; - typedef typename _Base::hasher hasher; - typedef typename _Base::key_equal key_equal; - 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 typename _Base::reference reference; - typedef typename _Base::const_reference const_reference; - - typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, - hash_multiset> iterator; - typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator, - hash_multiset> const_iterator; - - typedef typename _Base::allocator_type allocator_type; - - using _Base::hash_funct; - using _Base::key_eq; - using _Base::get_allocator; - - hash_multiset() { } - - explicit hash_multiset(size_type __n) : _Base(__n) { } - - hash_multiset(size_type __n, const hasher& __hf) : _Base(__n, __hf) { } - - hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__n, __hf, __eql, __a) - { } - - template<typename _InputIterator> - hash_multiset(_InputIterator __f, _InputIterator __l) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l) - { } - - template<typename _InputIterator> - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) - { } - - template<typename _InputIterator> - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) - { } - - template<typename _InputIterator> - hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf, - __eql, __a) - { } - - hash_multiset(const _Base& __x) : _Base(__x), _Safe_base() { } - - using _Base::size; - using _Base::max_size; - using _Base::empty; - - void - swap(hash_multiset& __x) - { - _Base::swap(__x); - this->_M_swap(__x); - } - - iterator begin() const { return iterator(_Base::begin(), this); } - iterator end() const { return iterator(_Base::end(), this); } - - iterator - insert(const value_type& __obj) - { return iterator(_Base::insert(__obj), this); } - - template <typename _InputIterator> - void - insert(_InputIterator __first, _InputIterator __last) - { - __glibcxx_check_valid_range(__first, __last); - _Base::insert(__first.base(), __last.base()); - } - - - iterator - insert_noresize(const value_type& __obj) - { return iterator(_Base::insert_noresize(__obj), this); } - - iterator - find(const key_type& __key) const - { return iterator(_Base::find(__key), this); } - - using _Base::count; - - std::pair<iterator, iterator> - equal_range(const key_type& __key) const - { - typedef typename _Base::iterator _Base_iterator; - std::pair<_Base_iterator, _Base_iterator> __res = - _Base::equal_range(__key); - return std::make_pair(iterator(__res.first, this), - iterator(__res.second, this)); - } - - size_type - erase(const key_type& __key) - { - size_type __count = 0; - std::pair<iterator, iterator> __victims = this->equal_range(__key); - while (__victims.first != __victims.second) - { - this->erase(__victims++); - ++__count; - } - return __count; - } - - void - erase(iterator __it) - { - __glibcxx_check_erase(__it); - __it._M_invalidate(); - _Base::erase(__it.base()); - } - - void - erase(iterator __first, iterator __last) - { - __glibcxx_check_erase_range(__first, __last); - for (iterator __tmp = __first; __tmp != __last;) - { - iterator __victim = __tmp++; - __victim._M_invalidate(); - } - _Base::erase(__first.base(), __last.base()); - } - - void - clear() - { - _Base::clear(); - this->_M_invalidate_all(); - } - - using _Base::resize; - using _Base::bucket_count; - using _Base::max_bucket_count; - using _Base::elems_in_bucket; - - _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<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc> - inline bool - operator==(const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x, - const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y) - { return __x._M_base() == __y._M_base(); } - -template<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc> - inline bool - operator!=(const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x, - const hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y) - { return __x._M_base() != __y._M_base(); } - -template<typename _Value, typename _HashFcn, typename _EqualKey, typename _Alloc> - inline void - swap(hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __x, - hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>& __y) - { __x.swap(__y); } -} // namespace __debug -} // namespace __gnu_cxx - -#endif diff --git a/libstdc++-v3/include/debug/hash_set b/libstdc++-v3/include/debug/hash_set deleted file mode 100644 index 4b98fefab1f..00000000000 --- a/libstdc++-v3/include/debug/hash_set +++ /dev/null @@ -1,42 +0,0 @@ -// Debugging hash_set/hash_multiset implementation -*- C++ -*- - -// Copyright (C) 2003, 2005 -// 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/hash_set - * This file is a GNU debug extension to the Standard C++ Library. - */ - -#ifndef _GLIBCXX_DEBUG_HASH_SET -#define _GLIBCXX_DEBUG_HASH_SET 1 - -#include <ext/hash_set> -#include <debug/hash_set.h> -#include <debug/hash_multiset.h> - -#endif diff --git a/libstdc++-v3/include/debug/hash_set.h b/libstdc++-v3/include/debug/safe_association.h index 9178063289b..dcb9ab44dbc 100644 --- a/libstdc++-v3/include/debug/hash_set.h +++ b/libstdc++-v3/include/debug/safe_association.h @@ -1,6 +1,6 @@ -// Debugging hash_set implementation -*- C++ -*- +// Safe associated container base class implementation -*- C++ -*- -// Copyright (C) 2003, 2005, 2006, 2007 +// Copyright (C) 2007 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -28,110 +28,110 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -/** @file debug/hash_set.h +/** @file debug/safe_association.h * This file is a GNU debug extension to the Standard C++ Library. */ -#ifndef _GLIBCXX_DEBUG_HASH_SET_H -#define _GLIBCXX_DEBUG_HASH_SET_H 1 +#ifndef _GLIBCXX_DEBUG_SAFE_ASSOCIATION_H +#define _GLIBCXX_DEBUG_SAFE_ASSOCIATION_H 1 +#include <debug/debug.h> +#include <debug/macros.h> +#include <debug/functions.h> +#include <debug/formatter.h> #include <debug/safe_sequence.h> -#include <debug/safe_iterator.h> -namespace __gnu_cxx +namespace __gnu_debug { -namespace __debug -{ - template<typename _Value, - typename _HashFcn = __gnu_cxx::hash<_Value>, - typename _EqualKey = std::equal_to<_Value>, - typename _Alloc = std::allocator<_Value> > - class hash_set - : public _GLIBCXX_EXT_D::hash_set<_Value, _HashFcn, _EqualKey,_Alloc>, - public __gnu_debug::_Safe_sequence<hash_set<_Value, _HashFcn, _EqualKey, - _Alloc> > + /** + * @brief Base class for constructing a "safe" associated container type. + * + * The class template %_Safe_association simplifies the construction of + * "safe" associated containers. + */ + template<typename _Base> + class _Safe_association + : public _Base { - typedef _GLIBCXX_EXT_D::hash_set<_Value, _HashFcn, _EqualKey,_Alloc> _Base; - typedef __gnu_debug::_Safe_sequence<hash_set> _Safe_base; - public: - typedef typename _Base::key_type key_type; - typedef typename _Base::value_type value_type; + typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; - typedef typename _Base::size_type size_type; + typedef typename _Base::allocator_type allocator_type; + + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; typedef typename _Base::difference_type difference_type; - typedef typename _Base::pointer pointer; - typedef typename _Base::const_pointer const_pointer; typedef typename _Base::reference reference; typedef typename _Base::const_reference const_reference; - typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, hash_set> + typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, + _Safe_association> iterator; typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator, - hash_set> + _Safe_association> const_iterator; - typedef typename _Base::allocator_type allocator_type; + _Safe_association() { } - using _Base::hash_funct; - using _Base::key_eq; - using _Base::get_allocator; - - hash_set() { } + explicit _Safe_association(size_type __n) : _Base(__n) { } - explicit hash_set(size_type __n) : _Base(__n) { } + _Safe_association(size_type __n, const hasher& __hf) + : _Base(__n, __hf) { } - hash_set(size_type __n, const hasher& __hf) : _Base(__n, __hf) { } - - hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) + _Safe_association(size_type __n, const hasher& __hf, + const key_equal& __eql, + const allocator_type& __a = allocator_type()) : _Base(__n, __hf, __eql, __a) { } - template<typename _InputIterator> - hash_set(_InputIterator __f, _InputIterator __l) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { } + template<typename _InputIter> + _Safe_association(_InputIter __f, _InputIter __l) + : _Base(__gnu_debug::__check_valid_range(__f, __l), __l) { } - template<typename _InputIterator> - hash_set(_InputIterator __f, _InputIterator __l, size_type __n) + template<typename _InputIter> + _Safe_association(_InputIter __f, _InputIter __l, size_type __n) : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n) { } - template<typename _InputIterator> - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) { } + template<typename _InputIter> + _Safe_association(_InputIter __f, _InputIter __l, size_type __n, + const hasher& __hf) + : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf) + { } - template<typename _InputIterator> - hash_set(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) - : _Base(__gnu_debug::__check_valid_range(__f, __l), __l, __n, __hf, - __eql, __a) { } + template<typename _InputIter> + _Safe_association(_InputIter __f, _InputIter __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _Base(__gnu_debug::__check_valid_range(__f, __l), + __l, __n, __hf, __eql, __a) + { } - hash_set(const _Base& __x) : _Base(__x), _Safe_base() { } + _Safe_association(const _Base& __x) : _Base(__x) { } using _Base::size; using _Base::max_size; using _Base::empty; + using _Base::get_allocator; + using _Base::key_eq; - void - swap(hash_set& __x) - { - _Base::swap(__x); - this->_M_swap(__x); - } + using _Base::count; + using _Base::bucket_count; + using _Base::max_bucket_count; + using _Base::bucket; + using _Base::bucket_size; + using _Base::load_factor; - iterator - begin() const { return iterator(_Base::begin(), this); } + const_iterator + begin() const { return const_iterator(_Base::begin(), this); } - iterator - end() const { return iterator(_Base::end(), this); } + const_iterator + end() const { return const_iterator(_Base::end(), this); } std::pair<iterator, bool> insert(const value_type& __obj) { - std::pair<typename _Base::iterator, bool> __res = - _Base::insert(__obj); + typedef std::pair<typename _Base::iterator, bool> __pair_type; + __pair_type __res = _Base::insert(__obj); return std::make_pair(iterator(__res.first, this), __res.second); } @@ -142,58 +142,50 @@ namespace __debug _Base::insert(__first, __last); } - template<typename _InputIterator> + template<typename _InputIter> void - insert(_InputIterator __first, _InputIterator __last) + insert(_InputIter __first, _InputIter __last) { __glibcxx_check_valid_range(__first, __last); _Base::insert(__first.base(), __last.base()); } - - std::pair<iterator, bool> - insert_noresize(const value_type& __obj) - { - std::pair<typename _Base::iterator, bool> __res = - _Base::insert_noresize(__obj); - return std::make_pair(iterator(__res.first, this), __res.second); - } - - iterator + const_iterator find(const key_type& __key) const - { return iterator(_Base::find(__key), this); } + { return const_iterator(_Base::find(__key), this); } - using _Base::count; - - std::pair<iterator, iterator> + std::pair<const_iterator, const_iterator> equal_range(const key_type& __key) const { - typedef typename _Base::iterator _Base_iterator; - std::pair<_Base_iterator, _Base_iterator> __res = - _Base::equal_range(__key); - return std::make_pair(iterator(__res.first, this), - iterator(__res.second, this)); + typedef typename _Base::const_iterator _Base_iterator; + typedef std::pair<_Base_iterator, _Base_iterator> __pair_type; + __pair_type __res = _Base::equal_range(__key); + return std::make_pair(const_iterator(__res.first, this), + const_iterator(__res.second, this)); } size_type erase(const key_type& __key) { + size_type __ret(0); iterator __victim(_Base::find(__key), this); if (__victim != end()) - return this->erase(__victim), 1; - else - return 0; + { + this->erase(__victim); + __ret = 1; + } + return __ret; } - void + iterator erase(iterator __it) { __glibcxx_check_erase(__it); __it._M_invalidate(); - _Base::erase(__it.base()); + return iterator(_Base::erase(__it.base())); } - void + iterator erase(iterator __first, iterator __last) { __glibcxx_check_erase_range(__first, __last); @@ -202,7 +194,7 @@ namespace __debug iterator __victim = __tmp++; __victim._M_invalidate(); } - _Base::erase(__first.base(), __last.base()); + return iterator(_Base::erase(__first.base(), __last.base())); } void @@ -212,13 +204,8 @@ namespace __debug this->_M_invalidate_all(); } - using _Base::resize; - using _Base::bucket_count; - using _Base::max_bucket_count; - using _Base::elems_in_bucket; - _Base& - _M_base() { return *this; } + _M_base() { return *this; } const _Base& _M_base() const { return *this; } @@ -232,28 +219,6 @@ namespace __debug this->_M_invalidate_if(_Not_equal(_M_base().end())); } }; - - template<typename _Value, typename _HashFcn, typename _EqualKey, - typename _Alloc> - inline bool - operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x, - const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y) - { return __x._M_base() == __y._M_base(); } - - template<typename _Value, typename _HashFcn, typename _EqualKey, - typename _Alloc> - inline bool - operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x, - const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y) - { return __x._M_base() != __y._M_base(); } - - template<typename _Value, typename _HashFcn, typename _EqualKey, - typename _Alloc> - inline void - swap(hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __x, - hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __y) - { __x.swap(__y); } -} // namespace __debug -} // namespace __gnu_cxx +} // namespace __gnu_debug #endif diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map new file mode 100644 index 00000000000..a88a972aa7f --- /dev/null +++ b/libstdc++-v3/include/debug/unordered_map @@ -0,0 +1,199 @@ +// Debugging unordered_map/unordered_multimap implementation -*- C++ -*- + +// Copyright (C) 2003, 2005, 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 <unordered_map> +#else +# include <c++0x_warning.h> +#endif +#include <debug/safe_association.h> +#include <debug/safe_iterator.h> + +#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 _Key, typename _Tp, + typename _Hash = std::hash<_Key>, + 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<unordered_map> _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<typename _InputIterator> + 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() { } + + void + swap(unordered_map& __x) + { + _Safe_assoc::swap(__x); + _Safe_base::_M_swap(__x); + } + }; + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() != __y._M_base(); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + 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 _Key, typename _Tp, + typename _Hash = std::hash<_Key>, + 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<unordered_multimap> _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<typename _InputIterator> + 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() { } + + void + swap(unordered_multimap& __x) + { + _Safe_assoc::swap(__x); + _Safe_base::_M_swap(__x); + } + }; + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() != __y._M_base(); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + 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 diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set new file mode 100644 index 00000000000..a49b4b06019 --- /dev/null +++ b/libstdc++-v3/include/debug/unordered_set @@ -0,0 +1,192 @@ +// Debugging unordered_set/unordered_multiset implementation -*- C++ -*- + +// Copyright (C) 2003, 2005, 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 <unordered_set> +#else +# include <c++0x_warning.h> +#endif + +#include <debug/safe_association.h> +#include <debug/safe_iterator.h> + +#define _GLIBCXX_BASE unordered_set<_Value, _Hash, _Pred, _Alloc> +#define _GLIBCXX_STD_BASE _GLIBCXX_STD_D::_GLIBCXX_BASE + +namespace std +{ +namespace __debug +{ + template<typename _Value, + typename _Hash = std::hash<_Value>, + 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<unordered_set> _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<typename _InputIterator> + 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() { } + + void + swap(unordered_set& __x) + { + _Safe_assoc::swap(__x); + _Safe_base::_M_swap(__x); + } + }; + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() != __y._M_base(); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + 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 _Value, + typename _Hash = std::hash<_Value>, + 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<unordered_multiset> _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<typename _InputIterator> + 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() { } + + void + swap(unordered_multiset& __x) + { + _Safe_assoc::swap(__x); + _Safe_base::_M_swap(__x); + } + }; + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() != __y._M_base(); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + 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 |

