29 #ifndef _GLIBCXX_DEBUG_MAP_H 30 #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> > >
46 map<_Key, _Tp, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
50 typedef _GLIBCXX_STD_C::map<
51 _Key, _Tp, _Compare, _Allocator>
_Base;
61 typedef _Key key_type;
62 typedef _Tp mapped_type;
64 typedef _Compare key_compare;
65 typedef _Allocator allocator_type;
66 typedef typename _Base::reference reference;
67 typedef typename _Base::const_reference const_reference;
74 typedef typename _Base::size_type size_type;
75 typedef typename _Base::difference_type difference_type;
76 typedef typename _Base::pointer pointer;
77 typedef typename _Base::const_pointer const_pointer;
83 #if __cplusplus < 201103L 92 map(
const map&) =
default;
96 const _Compare& __c = _Compare(),
97 const allocator_type& __a = allocator_type())
98 : _Base(__l, __c, __a) { }
101 map(
const allocator_type& __a)
104 map(
const map& __m,
const allocator_type& __a)
105 : _Base(__m, __a) { }
107 map(map&& __m,
const allocator_type& __a)
108 : _Safe(std::move(__m._M_safe()), __a),
109 _Base(std::move(__m._M_base()), __a) { }
112 : _Base(__l, __a) { }
114 template<
typename _InputIterator>
115 map(_InputIterator __first, _InputIterator __last,
116 const allocator_type& __a)
125 map(
const _Base& __x)
128 explicit map(
const _Compare& __comp,
129 const _Allocator& __a = _Allocator())
130 : _Base(__comp, __a) { }
132 template<
typename _InputIterator>
133 map(_InputIterator __first, _InputIterator __last,
134 const _Compare& __comp = _Compare(),
135 const _Allocator& __a = _Allocator())
141 #if __cplusplus < 201103L 143 operator=(
const map& __x)
145 this->_M_safe() = __x;
151 operator=(
const map&) =
default;
154 operator=(map&&) =
default;
160 this->_M_invalidate_all();
167 using _Base::get_allocator;
171 begin() _GLIBCXX_NOEXCEPT
172 {
return iterator(_Base::begin(),
this); }
175 begin()
const _GLIBCXX_NOEXCEPT
176 {
return const_iterator(_Base::begin(),
this); }
179 end() _GLIBCXX_NOEXCEPT
180 {
return iterator(_Base::end(),
this); }
183 end()
const _GLIBCXX_NOEXCEPT
184 {
return const_iterator(_Base::end(),
this); }
187 rbegin() _GLIBCXX_NOEXCEPT
188 {
return reverse_iterator(end()); }
190 const_reverse_iterator
191 rbegin()
const _GLIBCXX_NOEXCEPT
192 {
return const_reverse_iterator(end()); }
195 rend() _GLIBCXX_NOEXCEPT
196 {
return reverse_iterator(begin()); }
198 const_reverse_iterator
199 rend()
const _GLIBCXX_NOEXCEPT
200 {
return const_reverse_iterator(begin()); }
202 #if __cplusplus >= 201103L 204 cbegin()
const noexcept
205 {
return const_iterator(_Base::begin(),
this); }
208 cend()
const noexcept
209 {
return const_iterator(_Base::end(),
this); }
211 const_reverse_iterator
212 crbegin()
const noexcept
213 {
return const_reverse_iterator(end()); }
215 const_reverse_iterator
216 crend()
const noexcept
217 {
return const_reverse_iterator(begin()); }
223 using _Base::max_size;
226 using _Base::operator[];
233 #if __cplusplus >= 201103L 234 template<
typename... _Args>
236 emplace(_Args&&... __args)
238 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
243 template<
typename... _Args>
245 emplace_hint(const_iterator __pos, _Args&&... __args)
248 return iterator(_Base::emplace_hint(__pos.
base(),
249 std::forward<_Args>(__args)...),
255 insert(
const value_type& __x)
262 #if __cplusplus >= 201103L 263 template<
typename _Pair,
typename =
typename 264 std::enable_if<std::is_constructible<value_type,
265 _Pair&&>::value>::type>
270 = _Base::insert(std::forward<_Pair>(__x));
276 #if __cplusplus >= 201103L 279 { _Base::insert(__list); }
283 #if __cplusplus >= 201103L 284 insert(const_iterator __position,
const value_type& __x)
286 insert(iterator __position,
const value_type& __x)
290 return iterator(_Base::insert(__position.
base(), __x),
this);
293 #if __cplusplus >= 201103L 294 template<
typename _Pair,
typename =
typename 295 std::enable_if<std::is_constructible<value_type,
296 _Pair&&>::value>::type>
298 insert(const_iterator __position, _Pair&& __x)
301 return iterator(_Base::insert(__position.
base(),
302 std::forward<_Pair>(__x)),
this);
306 template<
typename _InputIterator>
308 insert(_InputIterator __first, _InputIterator __last)
310 __glibcxx_check_valid_range(__first, __last);
315 #if __cplusplus >= 201103L 317 erase(const_iterator __position)
321 return iterator(_Base::erase(__position.
base()),
this);
325 erase(iterator __position)
326 {
return erase(const_iterator(__position)); }
329 erase(iterator __position)
333 _Base::erase(__position.
base());
338 erase(
const key_type& __x)
340 _Base_iterator __victim = _Base::find(__x);
341 if (__victim == _Base::end())
346 _Base::erase(__victim);
351 #if __cplusplus >= 201103L 353 erase(const_iterator __first, const_iterator __last)
358 for (_Base_const_iterator __victim = __first.
base();
359 __victim != __last.
base(); ++__victim)
361 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
362 _M_message(__gnu_debug::__msg_valid_range)
363 ._M_iterator(__first,
"first")
364 ._M_iterator(__last,
"last"));
367 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
371 erase(iterator __first, iterator __last)
376 for (_Base_iterator __victim = __first.
base();
377 __victim != __last.
base(); ++__victim)
379 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
380 _M_message(__gnu_debug::__msg_valid_range)
381 ._M_iterator(__first,
"first")
382 ._M_iterator(__last,
"last"));
385 _Base::erase(__first.
base(), __last.
base());
391 #if __cplusplus >= 201103L 392 noexcept( noexcept(declval<_Base>().swap(__x)) )
400 clear() _GLIBCXX_NOEXCEPT
402 this->_M_invalidate_all();
407 using _Base::key_comp;
408 using _Base::value_comp;
412 find(
const key_type& __x)
413 {
return iterator(_Base::find(__x),
this); }
416 find(
const key_type& __x)
const 417 {
return const_iterator(_Base::find(__x),
this); }
422 lower_bound(
const key_type& __x)
423 {
return iterator(_Base::lower_bound(__x),
this); }
426 lower_bound(
const key_type& __x)
const 427 {
return const_iterator(_Base::lower_bound(__x),
this); }
430 upper_bound(
const key_type& __x)
431 {
return iterator(_Base::upper_bound(__x),
this); }
434 upper_bound(
const key_type& __x)
const 435 {
return const_iterator(_Base::upper_bound(__x),
this); }
438 equal_range(
const key_type& __x)
441 _Base::equal_range(__x);
443 iterator(__res.
second,
this));
447 equal_range(
const key_type& __x)
const 450 _Base::equal_range(__x);
452 const_iterator(__res.
second,
this));
456 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
459 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
462 template<
typename _Key,
typename _Tp,
463 typename _Compare,
typename _Allocator>
467 {
return __lhs._M_base() == __rhs._M_base(); }
469 template<
typename _Key,
typename _Tp,
470 typename _Compare,
typename _Allocator>
474 {
return __lhs._M_base() != __rhs._M_base(); }
476 template<
typename _Key,
typename _Tp,
477 typename _Compare,
typename _Allocator>
479 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
481 {
return __lhs._M_base() < __rhs._M_base(); }
483 template<
typename _Key,
typename _Tp,
484 typename _Compare,
typename _Allocator>
486 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
488 {
return __lhs._M_base() <= __rhs._M_base(); }
490 template<
typename _Key,
typename _Tp,
491 typename _Compare,
typename _Allocator>
495 {
return __lhs._M_base() >= __rhs._M_base(); }
497 template<
typename _Key,
typename _Tp,
498 typename _Compare,
typename _Allocator>
502 {
return __lhs._M_base() > __rhs._M_base(); }
504 template<
typename _Key,
typename _Tp,
505 typename _Compare,
typename _Allocator>
509 { __lhs.swap(__rhs); }
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
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.
_Iterator & base() noexcept
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
Safe class dealing with some allocator dependent operations.
Class std::map with safety/checking/debug instrumentation.
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
_T2 second
first is a copy of the first object
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Struct holding two objects of arbitrary type.
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
#define __glibcxx_check_insert(_Position)