29 #ifndef _GLIBCXX_DEBUG_MULTIMAP_H 30 #define _GLIBCXX_DEBUG_MULTIMAP_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 multimap<_Key, _Tp, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>
50 typedef _GLIBCXX_STD_C::multimap<
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 96 const _Compare& __c = _Compare(),
97 const allocator_type& __a = allocator_type())
98 :
_Base(__l, __c, __a) { }
105 :
_Base(__m, __a) { }
108 noexcept( noexcept(
_Base(std::move(__m._M_base()), __a)) )
109 :
_Safe(std::move(__m._M_safe()), __a),
110 _Base(std::move(__m._M_base()), __a) { }
113 :
_Base(__l, __a) { }
115 template<
typename _InputIterator>
116 multimap(_InputIterator __first, _InputIterator __last,
117 const allocator_type& __a)
118 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
120 __gnu_debug::__base(__last), __a) { }
125 explicit multimap(
const _Compare& __comp,
126 const _Allocator& __a = _Allocator())
127 :
_Base(__comp, __a) { }
129 template<
typename _InputIterator>
130 multimap(_InputIterator __first, _InputIterator __last,
131 const _Compare& __comp = _Compare(),
132 const _Allocator& __a = _Allocator())
133 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
135 __gnu_debug::__base(__last),
141 #if __cplusplus < 201103L 145 this->_M_safe() = __x;
151 operator=(
const multimap&) =
default;
160 this->_M_invalidate_all();
165 using _Base::get_allocator;
169 begin() _GLIBCXX_NOEXCEPT
170 {
return iterator(_Base::begin(),
this); }
173 begin()
const _GLIBCXX_NOEXCEPT
177 end() _GLIBCXX_NOEXCEPT
178 {
return iterator(_Base::end(),
this); }
181 end()
const _GLIBCXX_NOEXCEPT
185 rbegin() _GLIBCXX_NOEXCEPT
189 rbegin()
const _GLIBCXX_NOEXCEPT
193 rend() _GLIBCXX_NOEXCEPT
197 rend()
const _GLIBCXX_NOEXCEPT
200 #if __cplusplus >= 201103L 202 cbegin()
const noexcept
206 cend()
const noexcept
210 crbegin()
const noexcept
214 crend()
const noexcept
221 using _Base::max_size;
224 #if __cplusplus >= 201103L 225 template<
typename... _Args>
227 emplace(_Args&&... __args)
229 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
232 template<
typename... _Args>
238 std::forward<_Args>(__args)...),
245 {
return iterator(_Base::insert(__x),
this); }
247 #if __cplusplus >= 201103L 252 {
return { _Base::insert(std::move(__x)),
this }; }
254 template<
typename _Pair,
typename =
typename 256 _Pair&&>::value>::type>
259 {
return iterator(_Base::insert(std::forward<_Pair>(__x)),
this); }
262 #if __cplusplus >= 201103L 265 { _Base::insert(__list); }
269 #if __cplusplus >= 201103L 276 return iterator(_Base::insert(__position.
base(), __x),
this);
279 #if __cplusplus >= 201103L 286 return { _Base::insert(__position.
base(), std::move(__x)),
this };
289 template<
typename _Pair,
typename =
typename 291 _Pair&&>::value>::type>
297 std::forward<_Pair>(__x)),
this);
301 template<
typename _InputIterator>
303 insert(_InputIterator __first, _InputIterator __last)
306 __glibcxx_check_valid_range2(__first, __last, __dist);
308 if (__dist.
second >= __gnu_debug::__dp_sign)
309 _Base::insert(__gnu_debug::__unsafe(__first),
310 __gnu_debug::__unsafe(__last));
312 _Base::insert(__first, __last);
315 #if __cplusplus > 201402L 316 using node_type =
typename _Base::node_type;
323 return _Base::extract(__position.
base());
327 extract(
const key_type& __key)
329 const auto __position = find(__key);
330 if (__position != end())
331 return extract(__position);
336 insert(node_type&& __nh)
337 {
return iterator(_Base::insert(std::move(__nh)),
this); }
343 return iterator(_Base::insert(__hint.
base(), std::move(__nh)),
this);
349 #if __cplusplus >= 201103L 367 _Base::erase(__position.
base());
372 erase(
const key_type& __x)
375 _Base::equal_range(__x);
376 size_type __count = 0;
378 while (__victim != __victims.
second)
381 _Base::erase(__victim++);
387 #if __cplusplus >= 201103L 395 __victim != __last.
base(); ++__victim)
397 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
398 _M_message(__gnu_debug::__msg_valid_range)
399 ._M_iterator(__first,
"first")
400 ._M_iterator(__last,
"last"));
413 __victim != __last.
base(); ++__victim)
415 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
416 _M_message(__gnu_debug::__msg_valid_range)
417 ._M_iterator(__first,
"first")
418 ._M_iterator(__last,
"last"));
421 _Base::erase(__first.
base(), __last.
base());
427 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
434 clear() _GLIBCXX_NOEXCEPT
436 this->_M_invalidate_all();
441 using _Base::key_comp;
442 using _Base::value_comp;
446 find(
const key_type& __x)
447 {
return iterator(_Base::find(__x),
this); }
449 #if __cplusplus > 201103L 450 template<
typename _Kt,
452 typename __has_is_transparent<_Compare, _Kt>::type>
455 {
return { _Base::find(__x),
this }; }
459 find(
const key_type& __x)
const 462 #if __cplusplus > 201103L 463 template<
typename _Kt,
465 typename __has_is_transparent<_Compare, _Kt>::type>
467 find(
const _Kt& __x)
const 468 {
return { _Base::find(__x),
this }; }
474 lower_bound(
const key_type& __x)
475 {
return iterator(_Base::lower_bound(__x),
this); }
477 #if __cplusplus > 201103L 478 template<
typename _Kt,
480 typename __has_is_transparent<_Compare, _Kt>::type>
482 lower_bound(
const _Kt& __x)
483 {
return { _Base::lower_bound(__x),
this }; }
487 lower_bound(
const key_type& __x)
const 490 #if __cplusplus > 201103L 491 template<
typename _Kt,
493 typename __has_is_transparent<_Compare, _Kt>::type>
495 lower_bound(
const _Kt& __x)
const 496 {
return { _Base::lower_bound(__x),
this }; }
500 upper_bound(
const key_type& __x)
501 {
return iterator(_Base::upper_bound(__x),
this); }
503 #if __cplusplus > 201103L 504 template<
typename _Kt,
506 typename __has_is_transparent<_Compare, _Kt>::type>
508 upper_bound(
const _Kt& __x)
509 {
return { _Base::upper_bound(__x),
this }; }
513 upper_bound(
const key_type& __x)
const 516 #if __cplusplus > 201103L 517 template<
typename _Kt,
519 typename __has_is_transparent<_Compare, _Kt>::type>
521 upper_bound(
const _Kt& __x)
const 522 {
return { _Base::upper_bound(__x),
this }; }
526 equal_range(
const key_type& __x)
529 _Base::equal_range(__x);
534 #if __cplusplus > 201103L 535 template<
typename _Kt,
537 typename __has_is_transparent<_Compare, _Kt>::type>
539 equal_range(
const _Kt& __x)
541 auto __res = _Base::equal_range(__x);
542 return { { __res.first,
this }, { __res.second,
this } };
547 equal_range(
const key_type& __x)
const 550 _Base::equal_range(__x);
555 #if __cplusplus > 201103L 556 template<
typename _Kt,
558 typename __has_is_transparent<_Compare, _Kt>::type>
560 equal_range(
const _Kt& __x)
const 562 auto __res = _Base::equal_range(__x);
563 return { { __res.first,
this }, { __res.second,
this } };
568 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
571 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
574 #if __cpp_deduction_guides >= 201606 576 template<
typename _InputIterator,
579 typename = _RequireInputIter<_InputIterator>,
580 typename = _RequireAllocator<_Allocator>>
581 multimap(_InputIterator, _InputIterator,
582 _Compare = _Compare(), _Allocator = _Allocator())
584 _Compare, _Allocator>;
586 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
587 typename _Allocator = allocator<pair<const _Key, _Tp>>,
588 typename = _RequireAllocator<_Allocator>>
590 _Compare = _Compare(), _Allocator = _Allocator())
593 template<
typename _InputIterator,
typename _Allocator,
594 typename = _RequireInputIter<_InputIterator>,
595 typename = _RequireAllocator<_Allocator>>
596 multimap(_InputIterator, _InputIterator, _Allocator)
600 template<
typename _Key,
typename _Tp,
typename _Allocator,
601 typename = _RequireAllocator<_Allocator>>
607 template<
typename _Key,
typename _Tp,
608 typename _Compare,
typename _Allocator>
612 {
return __lhs._M_base() == __rhs._M_base(); }
614 template<
typename _Key,
typename _Tp,
615 typename _Compare,
typename _Allocator>
619 {
return __lhs._M_base() != __rhs._M_base(); }
621 template<
typename _Key,
typename _Tp,
622 typename _Compare,
typename _Allocator>
624 operator<(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
625 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
626 {
return __lhs._M_base() < __rhs._M_base(); }
628 template<
typename _Key,
typename _Tp,
629 typename _Compare,
typename _Allocator>
631 operator<=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
632 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
633 {
return __lhs._M_base() <= __rhs._M_base(); }
635 template<
typename _Key,
typename _Tp,
636 typename _Compare,
typename _Allocator>
638 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
639 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
640 {
return __lhs._M_base() >= __rhs._M_base(); }
642 template<
typename _Key,
typename _Tp,
643 typename _Compare,
typename _Allocator>
645 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
646 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
647 {
return __lhs._M_base() > __rhs._M_base(); }
649 template<
typename _Key,
typename _Tp,
650 typename _Compare,
typename _Allocator>
652 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
653 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
654 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
655 { __lhs.swap(__rhs); }
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
One of the comparison functors.
Struct holding two objects of arbitrary type.
The standard allocator, as per [20.4].
Define a member typedef type only if a boolean constant is true.
Class std::multimap with safety/checking/debug instrumentation.
#define __glibcxx_check_erase(_Position)
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.
#define __glibcxx_check_insert(_Position)
ISO C++ entities toplevel namespace is std.
_Iterator & base() noexcept
Return the underlying iterator.
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
_T1 first
second_type is the second bound type
_T2 second
first is a copy of the first object
Safe class dealing with some allocator dependent operations.