30 #ifndef _GLIBCXX_DEBUG_MAP_H
31 #define _GLIBCXX_DEBUG_MAP_H 1
37 namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
43 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
45 :
public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>,
48 typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
_Base;
56 typedef _Key key_type;
57 typedef _Tp mapped_type;
59 typedef _Compare key_compare;
60 typedef _Allocator allocator_type;
61 typedef typename _Base::reference reference;
62 typedef typename _Base::const_reference const_reference;
69 typedef typename _Base::size_type size_type;
70 typedef typename _Base::difference_type difference_type;
71 typedef typename _Base::pointer pointer;
72 typedef typename _Base::const_pointer const_pointer;
77 explicit map(
const _Compare& __comp = _Compare(),
78 const _Allocator& __a = _Allocator())
79 : _Base(__comp, __a) { }
81 template<
typename _InputIterator>
82 map(_InputIterator __first, _InputIterator __last,
83 const _Compare& __comp = _Compare(),
84 const _Allocator& __a = _Allocator())
88 __comp, __a), _Safe_base() { }
91 : _Base(__x), _Safe_base() { }
94 : _Base(__x), _Safe_base() { }
96 #ifdef __GXX_EXPERIMENTAL_CXX0X__
101 map(initializer_list<value_type> __l,
102 const _Compare& __c = _Compare(),
103 const allocator_type& __a = allocator_type())
104 : _Base(__l, __c, __a), _Safe_base() { }
110 operator=(
const map& __x)
112 *
static_cast<_Base*
>(
this) = __x;
113 this->_M_invalidate_all();
117 #ifdef __GXX_EXPERIMENTAL_CXX0X__
129 operator=(initializer_list<value_type> __l)
139 using _Base::get_allocator;
144 {
return iterator(_Base::begin(),
this); }
148 {
return const_iterator(_Base::begin(),
this); }
152 {
return iterator(_Base::end(),
this); }
156 {
return const_iterator(_Base::end(),
this); }
160 {
return reverse_iterator(end()); }
162 const_reverse_iterator
164 {
return const_reverse_iterator(end()); }
168 {
return reverse_iterator(begin()); }
170 const_reverse_iterator
172 {
return const_reverse_iterator(begin()); }
174 #ifdef __GXX_EXPERIMENTAL_CXX0X__
177 {
return const_iterator(_Base::begin(),
this); }
181 {
return const_iterator(_Base::end(),
this); }
183 const_reverse_iterator
185 {
return const_reverse_iterator(end()); }
187 const_reverse_iterator
189 {
return const_reverse_iterator(begin()); }
195 using _Base::max_size;
198 using _Base::operator[];
206 insert(
const value_type& __x)
214 #ifdef __GXX_EXPERIMENTAL_CXX0X__
215 template<
typename _Pair,
typename =
typename
216 std::enable_if<std::is_convertible<_Pair,
217 value_type>::value>::type>
223 = _Base::insert(std::forward<_Pair>(__x));
229 #ifdef __GXX_EXPERIMENTAL_CXX0X__
231 insert(std::initializer_list<value_type> __list)
232 { _Base::insert(__list); }
236 #ifdef __GXX_EXPERIMENTAL_CXX0X__
237 insert(const_iterator __position,
const value_type& __x)
239 insert(iterator __position,
const value_type& __x)
243 return iterator(_Base::insert(__position.
base(), __x),
this);
246 #ifdef __GXX_EXPERIMENTAL_CXX0X__
247 template<
typename _Pair,
typename =
typename
248 std::enable_if<std::is_convertible<_Pair,
249 value_type>::value>::type>
251 insert(const_iterator __position, _Pair&& __x)
254 return iterator(_Base::insert(__position.
base(),
255 std::forward<_Pair>(__x)),
this);
259 template<
typename _InputIterator>
261 insert(_InputIterator __first, _InputIterator __last)
263 __glibcxx_check_valid_range(__first, __last);
268 #ifdef __GXX_EXPERIMENTAL_CXX0X__
270 erase(const_iterator __position)
274 return iterator(_Base::erase(__position.
base()),
this);
278 erase(iterator __position)
279 {
return erase(const_iterator(__position)); }
282 erase(iterator __position)
286 _Base::erase(__position.
base());
291 erase(
const key_type& __x)
293 _Base_iterator __victim = _Base::find(__x);
294 if (__victim == _Base::end())
299 _Base::erase(__victim);
304 #ifdef __GXX_EXPERIMENTAL_CXX0X__
306 erase(const_iterator __first, const_iterator __last)
311 for (_Base_const_iterator __victim = __first.
base();
312 __victim != __last.
base(); ++__victim)
315 _M_message(__gnu_debug::__msg_valid_range)
316 ._M_iterator(__first,
"first")
317 ._M_iterator(__last,
"last"));
320 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
324 erase(iterator __first, iterator __last)
329 for (_Base_iterator __victim = __first.
base();
330 __victim != __last.
base(); ++__victim)
333 _M_message(__gnu_debug::__msg_valid_range)
334 ._M_iterator(__first,
"first")
335 ._M_iterator(__last,
"last"));
338 _Base::erase(__first.
base(), __last.
base());
352 this->_M_invalidate_all();
357 using _Base::key_comp;
358 using _Base::value_comp;
362 find(
const key_type& __x)
363 {
return iterator(_Base::find(__x),
this); }
366 find(
const key_type& __x)
const
367 {
return const_iterator(_Base::find(__x),
this); }
372 lower_bound(
const key_type& __x)
373 {
return iterator(_Base::lower_bound(__x),
this); }
376 lower_bound(
const key_type& __x)
const
377 {
return const_iterator(_Base::lower_bound(__x),
this); }
380 upper_bound(
const key_type& __x)
381 {
return iterator(_Base::upper_bound(__x),
this); }
384 upper_bound(
const key_type& __x)
const
385 {
return const_iterator(_Base::upper_bound(__x),
this); }
388 equal_range(
const key_type& __x)
392 _Base::equal_range(__x);
394 iterator(__res.
second,
this));
398 equal_range(
const key_type& __x)
const
402 _Base::equal_range(__x);
404 const_iterator(__res.
second,
this));
408 _M_base() {
return *
this; }
411 _M_base()
const {
return *
this; }
423 template<
typename _Key,
typename _Tp,
424 typename _Compare,
typename _Allocator>
428 {
return __lhs._M_base() == __rhs._M_base(); }
430 template<
typename _Key,
typename _Tp,
431 typename _Compare,
typename _Allocator>
435 {
return __lhs._M_base() != __rhs._M_base(); }
437 template<
typename _Key,
typename _Tp,
438 typename _Compare,
typename _Allocator>
440 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
441 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
442 {
return __lhs._M_base() < __rhs._M_base(); }
444 template<
typename _Key,
typename _Tp,
445 typename _Compare,
typename _Allocator>
447 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
448 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
449 {
return __lhs._M_base() <= __rhs._M_base(); }
451 template<
typename _Key,
typename _Tp,
452 typename _Compare,
typename _Allocator>
454 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
455 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
456 {
return __lhs._M_base() >= __rhs._M_base(); }
458 template<
typename _Key,
typename _Tp,
459 typename _Compare,
typename _Allocator>
461 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
462 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
463 {
return __lhs._M_base() > __rhs._M_base(); }
465 template<
typename _Key,
typename _Tp,
466 typename _Compare,
typename _Allocator>
468 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
469 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
470 { __lhs.swap(__rhs); }
Class std::map with safety/checking/debug instrumentation.
_Iterator base() const
Return the underlying iterator.
#define _GLIBCXX_DEBUG_VERIFY(_Condition, _ErrorMessage)
#define __glibcxx_check_erase(_Position)
void _M_invalidate_if(_Predicate __pred)
Base class for constructing a safe sequence type that tracks iterators that reference it...
#define __glibcxx_check_erase_range(_First, _Last)
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
_T2 second
first is a copy of the first object
ISO C++ entities toplevel namespace is std.
std::remove_reference< _Tp >::type && move(_Tp &&__t)
Move a value.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
void _M_swap(_Safe_sequence_base &__x)
Struct holding two objects of arbitrary type.
_T1 first
second_type is the second bound type
#define __glibcxx_check_insert(_Position)