1 // Debugging unordered_set/unordered_multiset implementation -*- C++ -*-
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 /** @file debug/unordered_set
32 * This file is a GNU debug extension to the Standard C++ Library.
35 #ifndef _GLIBCXX_DEBUG_UNORDERED_SET
36 #define _GLIBCXX_DEBUG_UNORDERED_SET 1
38 #ifdef __GXX_EXPERIMENTAL_CXX0X__
39 # include <unordered_set>
41 # include <c++0x_warning.h>
44 #include <debug/safe_association.h>
45 #include <debug/safe_iterator.h>
47 #define _GLIBCXX_BASE unordered_set<_Value, _Hash, _Pred, _Alloc>
48 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_D::_GLIBCXX_BASE
54 template<typename _Value,
55 typename _Hash = std::hash<_Value>,
56 typename _Pred = std::equal_to<_Value>,
57 typename _Alloc = std::allocator<_Value> >
59 : public __gnu_debug::_Safe_association<_GLIBCXX_STD_BASE>,
60 public __gnu_debug::_Safe_sequence<_GLIBCXX_BASE>
62 typedef typename _GLIBCXX_STD_BASE _Base;
63 typedef __gnu_debug::_Safe_association<_Base> _Safe_assoc;
64 typedef __gnu_debug::_Safe_sequence<unordered_set> _Safe_base;
67 typedef typename _Safe_assoc::size_type size_type;
68 typedef typename _Safe_assoc::hasher hasher;
69 typedef typename _Safe_assoc::key_equal key_equal;
70 typedef typename _Safe_assoc::allocator_type allocator_type;
73 unordered_set(size_type __n = 10,
74 const hasher& __hf = hasher(),
75 const key_equal& __eql = key_equal(),
76 const allocator_type& __a = allocator_type())
77 : _Safe_assoc(__n, __hf, __eql, __a)
80 template<typename _InputIterator>
81 unordered_set(_InputIterator __f, _InputIterator __l,
83 const hasher& __hf = hasher(),
84 const key_equal& __eql = key_equal(),
85 const allocator_type& __a = allocator_type())
86 : _Safe_assoc(__f, __l, __n, __hf, __eql, __a)
89 unordered_set(const _Safe_assoc& __x)
90 : _Safe_assoc(__x), _Safe_base() { }
92 unordered_set(unordered_set&& __x)
93 : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { }
96 operator=(unordered_set&& __x)
105 swap(unordered_set&& __x)
107 _Safe_assoc::swap(__x);
108 _Safe_base::_M_swap(__x);
115 this->_M_invalidate_all();
122 typedef typename _Base::const_iterator _Base_const_iterator;
123 typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
124 this->_M_invalidate_if(_Not_equal(this->_M_base().end()));
128 template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
130 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
131 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
134 template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
136 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x,
137 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
140 template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
142 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
143 unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y)
147 #undef _GLIBCXX_STD_BASE
148 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_D::_GLIBCXX_BASE
149 #define _GLIBCXX_BASE unordered_multiset<_Value, _Hash, _Pred, _Alloc>
151 template<typename _Value,
152 typename _Hash = std::hash<_Value>,
153 typename _Pred = std::equal_to<_Value>,
154 typename _Alloc = std::allocator<_Value> >
155 class unordered_multiset
156 : public __gnu_debug::_Safe_association<_GLIBCXX_STD_BASE>,
157 public __gnu_debug::_Safe_sequence<_GLIBCXX_BASE>
159 typedef typename _GLIBCXX_STD_BASE _Base;
160 typedef __gnu_debug::_Safe_association<_Base> _Safe_assoc;
161 typedef __gnu_debug::_Safe_sequence<unordered_multiset> _Safe_base;
164 typedef typename _Safe_assoc::size_type size_type;
165 typedef typename _Safe_assoc::hasher hasher;
166 typedef typename _Safe_assoc::key_equal key_equal;
167 typedef typename _Safe_assoc::allocator_type allocator_type;
170 unordered_multiset(size_type __n = 10,
171 const hasher& __hf = hasher(),
172 const key_equal& __eql = key_equal(),
173 const allocator_type& __a = allocator_type())
174 : _Safe_assoc(__n, __hf, __eql, __a)
177 template<typename _InputIterator>
178 unordered_multiset(_InputIterator __f, _InputIterator __l,
180 const hasher& __hf = hasher(),
181 const key_equal& __eql = key_equal(),
182 const allocator_type& __a = allocator_type())
183 : _Safe_assoc(__f, __l, __n, __hf, __eql, __a)
186 unordered_multiset(const _Safe_assoc& __x)
187 : _Safe_assoc(__x), _Safe_base() { }
189 unordered_multiset(unordered_multiset&& __x)
190 : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { }
193 operator=(unordered_multiset&& __x)
202 swap(unordered_multiset&& __x)
204 _Safe_assoc::swap(__x);
205 _Safe_base::_M_swap(__x);
212 this->_M_invalidate_all();
219 typedef typename _Base::const_iterator _Base_const_iterator;
220 typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal;
221 this->_M_invalidate_if(_Not_equal(this->_M_base().end()));
225 template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
227 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
228 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
231 template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
233 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x,
234 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
237 template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
239 swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
240 unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y)
243 } // namespace __debug
247 #undef _GLIBCXX_STD_BASE