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;
54 typedef _Key key_type;
55 typedef _Tp mapped_type;
57 typedef _Compare key_compare;
58 typedef _Allocator allocator_type;
59 typedef typename _Base::reference reference;
60 typedef typename _Base::const_reference const_reference;
67 typedef typename _Base::size_type size_type;
68 typedef typename _Base::difference_type difference_type;
69 typedef typename _Base::pointer pointer;
70 typedef typename _Base::const_pointer const_pointer;
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())
94 #if __cplusplus >= 201103L
96 noexcept(is_nothrow_copy_constructible<_Compare>::value)
100 map(initializer_list<value_type> __l,
101 const _Compare& __c = _Compare(),
102 const allocator_type& __a = allocator_type())
103 : _Base(__l, __c, __a) { }
106 ~
map() _GLIBCXX_NOEXCEPT { }
109 operator=(
const map& __x)
111 *
static_cast<_Base*
>(
this) = __x;
112 this->_M_invalidate_all();
116 #if __cplusplus >= 201103L
122 __glibcxx_check_self_move_assign(__x);
129 operator=(initializer_list<value_type> __l)
139 using _Base::get_allocator;
143 begin() _GLIBCXX_NOEXCEPT
144 {
return iterator(_Base::begin(),
this); }
147 begin()
const _GLIBCXX_NOEXCEPT
148 {
return const_iterator(_Base::begin(),
this); }
151 end() _GLIBCXX_NOEXCEPT
152 {
return iterator(_Base::end(),
this); }
155 end()
const _GLIBCXX_NOEXCEPT
156 {
return const_iterator(_Base::end(),
this); }
159 rbegin() _GLIBCXX_NOEXCEPT
160 {
return reverse_iterator(end()); }
162 const_reverse_iterator
163 rbegin()
const _GLIBCXX_NOEXCEPT
164 {
return const_reverse_iterator(end()); }
167 rend() _GLIBCXX_NOEXCEPT
168 {
return reverse_iterator(begin()); }
170 const_reverse_iterator
171 rend()
const _GLIBCXX_NOEXCEPT
172 {
return const_reverse_iterator(begin()); }
174 #if __cplusplus >= 201103L
176 cbegin()
const noexcept
177 {
return const_iterator(_Base::begin(),
this); }
180 cend()
const noexcept
181 {
return const_iterator(_Base::end(),
this); }
183 const_reverse_iterator
184 crbegin()
const noexcept
185 {
return const_reverse_iterator(end()); }
187 const_reverse_iterator
188 crend()
const noexcept
189 {
return const_reverse_iterator(begin()); }
195 using _Base::max_size;
198 using _Base::operator[];
205 #if __cplusplus >= 201103L
206 template<
typename... _Args>
208 emplace(_Args&&... __args)
210 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
215 template<
typename... _Args>
217 emplace_hint(const_iterator __pos, _Args&&... __args)
220 return iterator(_Base::emplace_hint(__pos.
base(),
221 std::forward<_Args>(__args)...),
227 insert(
const value_type& __x)
234 #if __cplusplus >= 201103L
235 template<
typename _Pair,
typename =
typename
236 std::enable_if<std::is_constructible<value_type,
237 _Pair&&>::value>::type>
242 = _Base::insert(std::forward<_Pair>(__x));
248 #if __cplusplus >= 201103L
250 insert(std::initializer_list<value_type> __list)
251 { _Base::insert(__list); }
255 #if __cplusplus >= 201103L
256 insert(const_iterator __position,
const value_type& __x)
258 insert(iterator __position,
const value_type& __x)
262 return iterator(_Base::insert(__position.
base(), __x),
this);
265 #if __cplusplus >= 201103L
266 template<
typename _Pair,
typename =
typename
267 std::enable_if<std::is_constructible<value_type,
268 _Pair&&>::value>::type>
270 insert(const_iterator __position, _Pair&& __x)
273 return iterator(_Base::insert(__position.
base(),
274 std::forward<_Pair>(__x)),
this);
278 template<
typename _InputIterator>
280 insert(_InputIterator __first, _InputIterator __last)
282 __glibcxx_check_valid_range(__first, __last);
287 #if __cplusplus >= 201103L
289 erase(const_iterator __position)
293 return iterator(_Base::erase(__position.
base()),
this);
297 erase(iterator __position)
298 {
return erase(const_iterator(__position)); }
301 erase(iterator __position)
305 _Base::erase(__position.
base());
310 erase(
const key_type& __x)
312 _Base_iterator __victim = _Base::find(__x);
313 if (__victim == _Base::end())
318 _Base::erase(__victim);
323 #if __cplusplus >= 201103L
325 erase(const_iterator __first, const_iterator __last)
330 for (_Base_const_iterator __victim = __first.
base();
331 __victim != __last.
base(); ++__victim)
333 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
334 _M_message(__gnu_debug::__msg_valid_range)
335 ._M_iterator(__first,
"first")
336 ._M_iterator(__last,
"last"));
339 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
343 erase(iterator __first, iterator __last)
348 for (_Base_iterator __victim = __first.
base();
349 __victim != __last.
base(); ++__victim)
351 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
352 _M_message(__gnu_debug::__msg_valid_range)
353 ._M_iterator(__first,
"first")
354 ._M_iterator(__last,
"last"));
357 _Base::erase(__first.
base(), __last.
base());
369 clear() _GLIBCXX_NOEXCEPT
371 this->_M_invalidate_all();
376 using _Base::key_comp;
377 using _Base::value_comp;
381 find(
const key_type& __x)
382 {
return iterator(_Base::find(__x),
this); }
385 find(
const key_type& __x)
const
386 {
return const_iterator(_Base::find(__x),
this); }
391 lower_bound(
const key_type& __x)
392 {
return iterator(_Base::lower_bound(__x),
this); }
395 lower_bound(
const key_type& __x)
const
396 {
return const_iterator(_Base::lower_bound(__x),
this); }
399 upper_bound(
const key_type& __x)
400 {
return iterator(_Base::upper_bound(__x),
this); }
403 upper_bound(
const key_type& __x)
const
404 {
return const_iterator(_Base::upper_bound(__x),
this); }
407 equal_range(
const key_type& __x)
410 _Base::equal_range(__x);
412 iterator(__res.
second,
this));
416 equal_range(
const key_type& __x)
const
419 _Base::equal_range(__x);
421 const_iterator(__res.
second,
this));
425 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
428 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
439 template<
typename _Key,
typename _Tp,
440 typename _Compare,
typename _Allocator>
444 {
return __lhs._M_base() == __rhs._M_base(); }
446 template<
typename _Key,
typename _Tp,
447 typename _Compare,
typename _Allocator>
451 {
return __lhs._M_base() != __rhs._M_base(); }
453 template<
typename _Key,
typename _Tp,
454 typename _Compare,
typename _Allocator>
456 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
457 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
458 {
return __lhs._M_base() < __rhs._M_base(); }
460 template<
typename _Key,
typename _Tp,
461 typename _Compare,
typename _Allocator>
463 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
464 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
465 {
return __lhs._M_base() <= __rhs._M_base(); }
467 template<
typename _Key,
typename _Tp,
468 typename _Compare,
typename _Allocator>
470 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
471 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
472 {
return __lhs._M_base() >= __rhs._M_base(); }
474 template<
typename _Key,
typename _Tp,
475 typename _Compare,
typename _Allocator>
477 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
478 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
479 {
return __lhs._M_base() > __rhs._M_base(); }
481 template<
typename _Key,
typename _Tp,
482 typename _Compare,
typename _Allocator>
484 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
485 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
486 { __lhs.swap(__rhs); }
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
#define __glibcxx_check_insert(_Position)
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Base class for constructing a safe sequence type that tracks iterators that reference 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_invalidate_if(_Predicate __pred)
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.
ISO C++ entities toplevel namespace is std.
void _M_swap(_Safe_sequence_base &__x)
_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...
Class std::map with safety/checking/debug instrumentation.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
_Iterator base() const
Return the underlying iterator.
#define __glibcxx_check_erase_range(_First, _Last)
Struct holding two objects of arbitrary type.
_T2 second
first is a copy of the first object
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.