29 #ifndef _GLIBCXX_DEBUG_MAP_H
30 #define _GLIBCXX_DEBUG_MAP_H 1
36 namespace std _GLIBCXX_VISIBILITY(default)
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_C::map<_Key, _Tp, _Compare, _Allocator>,
47 typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
_Base;
53 #if __cplusplus >= 201103L
59 typedef _Key key_type;
60 typedef _Tp mapped_type;
62 typedef _Compare key_compare;
63 typedef _Allocator allocator_type;
64 typedef typename _Base::reference reference;
65 typedef typename _Base::const_reference const_reference;
72 typedef typename _Base::size_type size_type;
73 typedef typename _Base::difference_type difference_type;
74 typedef typename _Base::pointer pointer;
75 typedef typename _Base::const_pointer const_pointer;
83 explicit map(
const _Compare& __comp,
84 const _Allocator& __a = _Allocator())
85 : _Base(__comp, __a) { }
87 template<
typename _InputIterator>
88 map(_InputIterator __first, _InputIterator __last,
89 const _Compare& __comp = _Compare(),
90 const _Allocator& __a = _Allocator())
102 #if __cplusplus >= 201103L
104 noexcept(is_nothrow_copy_constructible<_Compare>::value)
108 map(initializer_list<value_type> __l,
109 const _Compare& __c = _Compare(),
110 const allocator_type& __a = allocator_type())
111 : _Base(__l, __c, __a) { }
114 map(
const allocator_type& __a)
117 map(
const map& __m,
const allocator_type& __a)
118 : _Base(__m, __a) { }
120 map(
map&& __m,
const allocator_type& __a)
121 : _Base(
std::move(__m._M_base()), __a) { }
123 map(initializer_list<value_type> __l,
const allocator_type& __a)
124 : _Base(__l, __a) { }
126 template<
typename _InputIterator>
127 map(_InputIterator __first, _InputIterator __last,
128 const allocator_type& __a)
135 ~
map() _GLIBCXX_NOEXCEPT { }
138 operator=(
const map& __x)
141 this->_M_invalidate_all();
145 #if __cplusplus >= 201103L
148 noexcept(_Alloc_traits::_S_nothrow_move())
150 __glibcxx_check_self_move_assign(__x);
151 bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
152 || __x.get_allocator() == this->get_allocator();
157 this->_M_invalidate_all();
158 __x._M_invalidate_all();
163 operator=(initializer_list<value_type> __l)
166 this->_M_invalidate_all();
173 using _Base::get_allocator;
177 begin() _GLIBCXX_NOEXCEPT
178 {
return iterator(_Base::begin(),
this); }
181 begin()
const _GLIBCXX_NOEXCEPT
182 {
return const_iterator(_Base::begin(),
this); }
185 end() _GLIBCXX_NOEXCEPT
186 {
return iterator(_Base::end(),
this); }
189 end()
const _GLIBCXX_NOEXCEPT
190 {
return const_iterator(_Base::end(),
this); }
193 rbegin() _GLIBCXX_NOEXCEPT
194 {
return reverse_iterator(end()); }
196 const_reverse_iterator
197 rbegin()
const _GLIBCXX_NOEXCEPT
198 {
return const_reverse_iterator(end()); }
201 rend() _GLIBCXX_NOEXCEPT
202 {
return reverse_iterator(begin()); }
204 const_reverse_iterator
205 rend()
const _GLIBCXX_NOEXCEPT
206 {
return const_reverse_iterator(begin()); }
208 #if __cplusplus >= 201103L
210 cbegin()
const noexcept
211 {
return const_iterator(_Base::begin(),
this); }
214 cend()
const noexcept
215 {
return const_iterator(_Base::end(),
this); }
217 const_reverse_iterator
218 crbegin()
const noexcept
219 {
return const_reverse_iterator(end()); }
221 const_reverse_iterator
222 crend()
const noexcept
223 {
return const_reverse_iterator(begin()); }
229 using _Base::max_size;
232 using _Base::operator[];
239 #if __cplusplus >= 201103L
240 template<
typename... _Args>
242 emplace(_Args&&... __args)
244 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
249 template<
typename... _Args>
251 emplace_hint(const_iterator __pos, _Args&&... __args)
254 return iterator(_Base::emplace_hint(__pos.
base(),
255 std::forward<_Args>(__args)...),
261 insert(
const value_type& __x)
268 #if __cplusplus >= 201103L
269 template<
typename _Pair,
typename =
typename
270 std::enable_if<std::is_constructible<value_type,
271 _Pair&&>::value>::type>
276 = _Base::insert(std::forward<_Pair>(__x));
282 #if __cplusplus >= 201103L
284 insert(std::initializer_list<value_type> __list)
285 { _Base::insert(__list); }
289 #if __cplusplus >= 201103L
290 insert(const_iterator __position,
const value_type& __x)
292 insert(iterator __position,
const value_type& __x)
296 return iterator(_Base::insert(__position.
base(), __x),
this);
299 #if __cplusplus >= 201103L
300 template<
typename _Pair,
typename =
typename
301 std::enable_if<std::is_constructible<value_type,
302 _Pair&&>::value>::type>
304 insert(const_iterator __position, _Pair&& __x)
307 return iterator(_Base::insert(__position.
base(),
308 std::forward<_Pair>(__x)),
this);
312 template<
typename _InputIterator>
314 insert(_InputIterator __first, _InputIterator __last)
316 __glibcxx_check_valid_range(__first, __last);
321 #if __cplusplus >= 201103L
323 erase(const_iterator __position)
327 return iterator(_Base::erase(__position.
base()),
this);
331 erase(iterator __position)
332 {
return erase(const_iterator(__position)); }
335 erase(iterator __position)
339 _Base::erase(__position.
base());
344 erase(
const key_type& __x)
346 _Base_iterator __victim = _Base::find(__x);
347 if (__victim == _Base::end())
352 _Base::erase(__victim);
357 #if __cplusplus >= 201103L
359 erase(const_iterator __first, const_iterator __last)
364 for (_Base_const_iterator __victim = __first.
base();
365 __victim != __last.
base(); ++__victim)
367 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
368 _M_message(__gnu_debug::__msg_valid_range)
369 ._M_iterator(__first,
"first")
370 ._M_iterator(__last,
"last"));
373 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
377 erase(iterator __first, iterator __last)
382 for (_Base_iterator __victim = __first.
base();
383 __victim != __last.
base(); ++__victim)
385 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
386 _M_message(__gnu_debug::__msg_valid_range)
387 ._M_iterator(__first,
"first")
388 ._M_iterator(__last,
"last"));
391 _Base::erase(__first.
base(), __last.
base());
397 #if __cplusplus >= 201103L
398 noexcept(_Alloc_traits::_S_nothrow_swap())
401 #if __cplusplus >= 201103L
402 if (!_Alloc_traits::_S_propagate_on_swap())
403 __glibcxx_check_equal_allocs(__x);
410 clear() _GLIBCXX_NOEXCEPT
412 this->_M_invalidate_all();
417 using _Base::key_comp;
418 using _Base::value_comp;
422 find(
const key_type& __x)
423 {
return iterator(_Base::find(__x),
this); }
426 find(
const key_type& __x)
const
427 {
return const_iterator(_Base::find(__x),
this); }
432 lower_bound(
const key_type& __x)
433 {
return iterator(_Base::lower_bound(__x),
this); }
436 lower_bound(
const key_type& __x)
const
437 {
return const_iterator(_Base::lower_bound(__x),
this); }
440 upper_bound(
const key_type& __x)
441 {
return iterator(_Base::upper_bound(__x),
this); }
444 upper_bound(
const key_type& __x)
const
445 {
return const_iterator(_Base::upper_bound(__x),
this); }
448 equal_range(
const key_type& __x)
451 _Base::equal_range(__x);
453 iterator(__res.
second,
this));
457 equal_range(
const key_type& __x)
const
460 _Base::equal_range(__x);
462 const_iterator(__res.
second,
this));
466 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
469 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
480 template<
typename _Key,
typename _Tp,
481 typename _Compare,
typename _Allocator>
485 {
return __lhs._M_base() == __rhs._M_base(); }
487 template<
typename _Key,
typename _Tp,
488 typename _Compare,
typename _Allocator>
492 {
return __lhs._M_base() != __rhs._M_base(); }
494 template<
typename _Key,
typename _Tp,
495 typename _Compare,
typename _Allocator>
497 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
498 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
499 {
return __lhs._M_base() < __rhs._M_base(); }
501 template<
typename _Key,
typename _Tp,
502 typename _Compare,
typename _Allocator>
504 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
505 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
506 {
return __lhs._M_base() <= __rhs._M_base(); }
508 template<
typename _Key,
typename _Tp,
509 typename _Compare,
typename _Allocator>
511 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
512 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
513 {
return __lhs._M_base() >= __rhs._M_base(); }
515 template<
typename _Key,
typename _Tp,
516 typename _Compare,
typename _Allocator>
518 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
519 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
520 {
return __lhs._M_base() > __rhs._M_base(); }
522 template<
typename _Key,
typename _Tp,
523 typename _Compare,
typename _Allocator>
525 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
526 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
527 { __lhs.swap(__rhs); }
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr 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.
Uniform interface to C++98 and C++0x allocators.
Class std::map with safety/checking/debug instrumentation.
#define __glibcxx_check_insert(_Position)
Base class for constructing a safe sequence type that tracks iterators that reference it...
void _M_invalidate_if(_Predicate __pred)
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
void _M_swap(_Safe_sequence_base &__x)
_T1 first
second_type is the second bound type
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
ISO C++ entities toplevel namespace is std.
#define __glibcxx_check_erase(_Position)
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
Struct holding two objects of arbitrary type.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
_Iterator base() const noexcept
Return the underlying iterator.
_T2 second
first is a copy of the first object
#define __glibcxx_check_erase_range(_First, _Last)