30 #ifndef _GLIBCXX_DEBUG_MAP_H
31 #define _GLIBCXX_DEBUG_MAP_H 1
41 template<
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
42 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
44 :
public _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator>,
47 typedef _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator> _Base;
52 typedef _Key key_type;
53 typedef _Tp mapped_type;
55 typedef _Compare key_compare;
56 typedef _Allocator allocator_type;
57 typedef typename _Base::reference reference;
58 typedef typename _Base::const_reference const_reference;
65 typedef typename _Base::size_type size_type;
66 typedef typename _Base::difference_type difference_type;
67 typedef typename _Base::pointer pointer;
68 typedef typename _Base::const_pointer const_pointer;
72 using _Base::value_compare;
75 explicit map(
const _Compare& __comp = _Compare(),
76 const _Allocator& __a = _Allocator())
77 : _Base(__comp, __a) { }
79 template<
typename _InputIterator>
80 map(_InputIterator __first, _InputIterator __last,
81 const _Compare& __comp = _Compare(),
82 const _Allocator& __a = _Allocator())
83 : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
84 __comp, __a), _Safe_base() { }
87 : _Base(__x), _Safe_base() { }
90 : _Base(__x), _Safe_base() { }
92 #ifdef __GXX_EXPERIMENTAL_CXX0X__
94 : _Base(std::forward<map>(__x)), _Safe_base()
97 map(initializer_list<value_type> __l,
98 const _Compare& __c = _Compare(),
99 const allocator_type& __a = allocator_type())
100 : _Base(__l, __c, __a), _Safe_base() { }
106 operator=(
const map& __x)
108 *
static_cast<_Base*
>(
this) = __x;
113 #ifdef __GXX_EXPERIMENTAL_CXX0X__
124 operator=(initializer_list<value_type> __l)
134 using _Base::get_allocator;
139 {
return iterator(_Base::begin(),
this); }
143 {
return const_iterator(_Base::begin(),
this); }
147 {
return iterator(_Base::end(),
this); }
151 {
return const_iterator(_Base::end(),
this); }
155 {
return reverse_iterator(end()); }
157 const_reverse_iterator
159 {
return const_reverse_iterator(end()); }
163 {
return reverse_iterator(begin()); }
165 const_reverse_iterator
167 {
return const_reverse_iterator(begin()); }
169 #ifdef __GXX_EXPERIMENTAL_CXX0X__
172 {
return const_iterator(_Base::begin(),
this); }
176 {
return const_iterator(_Base::end(),
this); }
178 const_reverse_iterator
180 {
return const_reverse_iterator(end()); }
182 const_reverse_iterator
184 {
return const_reverse_iterator(begin()); }
190 using _Base::max_size;
193 using _Base::operator[];
201 insert(
const value_type& __x)
203 typedef typename _Base::iterator _Base_iterator;
209 #ifdef __GXX_EXPERIMENTAL_CXX0X__
212 { _Base::insert(__list); }
216 insert(iterator __position,
const value_type& __x)
219 return iterator(_Base::insert(__position.base(), __x),
this);
222 template<
typename _InputIterator>
224 insert(_InputIterator __first, _InputIterator __last)
226 __glibcxx_check_valid_range(__first, __last);
227 _Base::insert(__first, __last);
231 erase(iterator __position)
234 __position._M_invalidate();
235 _Base::erase(__position.base());
239 erase(
const key_type& __x)
241 iterator __victim = find(__x);
242 if (__victim == end())
246 __victim._M_invalidate();
247 _Base::erase(__victim.base());
253 erase(iterator __first, iterator __last)
258 while (__first != __last)
259 this->erase(__first++);
263 #ifdef __GXX_EXPERIMENTAL_CXX0X__
275 { this->erase(begin(), end()); }
278 using _Base::key_comp;
279 using _Base::value_comp;
283 find(
const key_type& __x)
284 {
return iterator(_Base::find(__x),
this); }
287 find(
const key_type& __x)
const
288 {
return const_iterator(_Base::find(__x),
this); }
293 lower_bound(
const key_type& __x)
294 {
return iterator(_Base::lower_bound(__x),
this); }
297 lower_bound(
const key_type& __x)
const
298 {
return const_iterator(_Base::lower_bound(__x),
this); }
301 upper_bound(
const key_type& __x)
302 {
return iterator(_Base::upper_bound(__x),
this); }
305 upper_bound(
const key_type& __x)
const
306 {
return const_iterator(_Base::upper_bound(__x),
this); }
309 equal_range(
const key_type& __x)
311 typedef typename _Base::iterator _Base_iterator;
313 _Base::equal_range(__x);
314 return std::make_pair(iterator(__res.
first,
this),
315 iterator(__res.
second,
this));
319 equal_range(
const key_type& __x)
const
321 typedef typename _Base::const_iterator _Base_const_iterator;
323 _Base::equal_range(__x);
324 return std::make_pair(const_iterator(__res.
first,
this),
325 const_iterator(__res.
second,
this));
329 _M_base() {
return *
this; }
332 _M_base()
const {
return *
this; }
338 typedef typename _Base::const_iterator _Base_const_iterator;
344 template<
typename _Key,
typename _Tp,
345 typename _Compare,
typename _Allocator>
347 operator==(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
348 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
349 {
return __lhs._M_base() == __rhs._M_base(); }
351 template<
typename _Key,
typename _Tp,
352 typename _Compare,
typename _Allocator>
354 operator!=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
355 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
356 {
return __lhs._M_base() != __rhs._M_base(); }
358 template<
typename _Key,
typename _Tp,
359 typename _Compare,
typename _Allocator>
361 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
362 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
363 {
return __lhs._M_base() < __rhs._M_base(); }
365 template<
typename _Key,
typename _Tp,
366 typename _Compare,
typename _Allocator>
368 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
369 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
370 {
return __lhs._M_base() <= __rhs._M_base(); }
372 template<
typename _Key,
typename _Tp,
373 typename _Compare,
typename _Allocator>
375 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
376 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
377 {
return __lhs._M_base() >= __rhs._M_base(); }
379 template<
typename _Key,
typename _Tp,
380 typename _Compare,
typename _Allocator>
382 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
383 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
384 {
return __lhs._M_base() > __rhs._M_base(); }
386 template<
typename _Key,
typename _Tp,
387 typename _Compare,
typename _Allocator>
389 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
390 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
391 { __lhs.swap(__rhs); }
393 #ifdef __GXX_EXPERIMENTAL_CXX0X__
394 template<
typename _Key,
typename _Tp,
395 typename _Compare,
typename _Allocator>
397 swap(map<_Key, _Tp, _Compare, _Allocator>&& __lhs,
398 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
399 { __lhs.swap(__rhs); }
401 template<
typename _Key,
typename _Tp,
402 typename _Compare,
typename _Allocator>
404 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
405 map<_Key, _Tp, _Compare, _Allocator>&& __rhs)
406 { __lhs.swap(__rhs); }
void _M_invalidate_if(_Predicate __pred)
pair holds two objects of arbitrary type.
#define __glibcxx_check_erase(_Position)
_T2 second
second is a copy of the second object
Base class for constructing a "safe" sequence type that tracks iterators that reference it...
_T1 first
first is a copy of the first object
void _M_invalidate_all() const
#define __glibcxx_check_erase_range(_First, _Last)
void _M_swap(_Safe_sequence_base &__x)
#define __glibcxx_check_insert(_Position)