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)
105 :
_Base(std::move(__x))
106 { this->_M_swap(__x); }
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) { }
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();
153 _M_base() = std::move(__x._M_base());
157 this->_M_invalidate_all();
158 __x._M_invalidate_all();
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
185 end() _GLIBCXX_NOEXCEPT
186 {
return iterator(_Base::end(),
this); }
189 end()
const _GLIBCXX_NOEXCEPT
193 rbegin() _GLIBCXX_NOEXCEPT
197 rbegin()
const _GLIBCXX_NOEXCEPT
201 rend() _GLIBCXX_NOEXCEPT
205 rend()
const _GLIBCXX_NOEXCEPT
208 #if __cplusplus >= 201103L
210 cbegin()
const noexcept
214 cend()
const noexcept
218 crbegin()
const noexcept
222 crend()
const noexcept
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>
255 std::forward<_Args>(__args)...),
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
285 { _Base::insert(__list); }
289 #if __cplusplus >= 201103L
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>
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
339 _Base::erase(__position.
base());
344 erase(
const key_type& __x)
347 if (__victim == _Base::end())
352 _Base::erase(__victim);
357 #if __cplusplus >= 201103L
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"));
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
432 lower_bound(
const key_type& __x)
433 {
return iterator(_Base::lower_bound(__x),
this); }
436 lower_bound(
const key_type& __x)
const
440 upper_bound(
const key_type& __x)
441 {
return iterator(_Base::upper_bound(__x),
this); }
444 upper_bound(
const key_type& __x)
const
448 equal_range(
const key_type& __x)
451 _Base::equal_range(__x);
457 equal_range(
const key_type& __x)
const
460 _Base::equal_range(__x);
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); }
Struct holding two objects of arbitrary type.
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_insert(_Position)
Uniform interface to C++98 and C++0x allocators.
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.
constexpr size_t size() const noexcept
Returns the total number of bits.
_T2 second
first is a copy of the first object
size_t count() const noexcept
Returns the number of bits which are set.
_Iterator base() const noexcept
Return the underlying iterator.
_T1 first
second_type is the second bound type
#define __glibcxx_check_erase(_Position)
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
Base class for constructing a safe sequence type that tracks iterators that reference it...
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Class std::map with safety/checking/debug instrumentation.
#define __glibcxx_check_erase_range(_First, _Last)