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;
59 template<
typename _ItT,
typename _SeqT,
typename _CatT>
60 friend class ::__gnu_debug::_Safe_iterator;
64 typedef _Key key_type;
65 typedef _Tp mapped_type;
67 typedef _Compare key_compare;
68 typedef _Allocator allocator_type;
69 typedef typename _Base::reference reference;
70 typedef typename _Base::const_reference const_reference;
77 typedef typename _Base::size_type size_type;
78 typedef typename _Base::difference_type difference_type;
79 typedef typename _Base::pointer pointer;
80 typedef typename _Base::const_pointer const_pointer;
86 #if __cplusplus < 201103L
99 const _Compare& __c = _Compare(),
100 const allocator_type& __a = allocator_type())
101 :
_Base(__l, __c, __a) { }
108 :
_Base(__m, __a) { }
116 :
_Base(__l, __a) { }
118 template<
typename _InputIterator>
119 multimap(_InputIterator __first, _InputIterator __last,
120 const allocator_type& __a)
122 __glibcxx_check_valid_constructor_range(__first, __last)),
128 explicit multimap(
const _Compare& __comp,
129 const _Allocator& __a = _Allocator())
130 :
_Base(__comp, __a) { }
132 template<
typename _InputIterator>
133 multimap(_InputIterator __first, _InputIterator __last,
134 const _Compare& __comp = _Compare(),
135 const _Allocator& __a = _Allocator())
137 __glibcxx_check_valid_constructor_range(__first, __last)),
144 #if __cplusplus < 201103L
148 this->_M_safe() = __x;
154 operator=(
const multimap&) =
default;
163 this->_M_invalidate_all();
168 using _Base::get_allocator;
172 begin() _GLIBCXX_NOEXCEPT
173 {
return iterator(_Base::begin(),
this); }
176 begin()
const _GLIBCXX_NOEXCEPT
180 end() _GLIBCXX_NOEXCEPT
181 {
return iterator(_Base::end(),
this); }
184 end()
const _GLIBCXX_NOEXCEPT
188 rbegin() _GLIBCXX_NOEXCEPT
192 rbegin()
const _GLIBCXX_NOEXCEPT
196 rend() _GLIBCXX_NOEXCEPT
200 rend()
const _GLIBCXX_NOEXCEPT
203 #if __cplusplus >= 201103L
205 cbegin()
const noexcept
209 cend()
const noexcept
213 crbegin()
const noexcept
217 crend()
const noexcept
224 using _Base::max_size;
227 #if __cplusplus >= 201103L
228 template<
typename... _Args>
230 emplace(_Args&&... __args)
231 {
return { _Base::emplace(std::forward<_Args>(__args)...),
this }; }
233 template<
typename... _Args>
240 _Base::emplace_hint(__pos.
base(), std::forward<_Args>(__args)...),
248 {
return iterator(_Base::insert(__x),
this); }
250 #if __cplusplus >= 201103L
255 {
return { _Base::insert(
std::move(__x)),
this }; }
257 template<
typename _Pair,
typename =
typename
259 _Pair&&>::value>::type>
262 {
return { _Base::insert(std::forward<_Pair>(__x)),
this }; }
265 #if __cplusplus >= 201103L
268 { _Base::insert(__list); }
272 #if __cplusplus >= 201103L
279 return iterator(_Base::insert(__position.
base(), __x),
this);
282 #if __cplusplus >= 201103L
289 return { _Base::insert(__position.
base(),
std::move(__x)),
this };
292 template<
typename _Pair,
typename =
typename
294 _Pair&&>::value>::type>
301 _Base::insert(__position.
base(), std::forward<_Pair>(__x)),
307 template<
typename _InputIterator>
309 insert(_InputIterator __first, _InputIterator __last)
312 __glibcxx_check_valid_range2(__first, __last, __dist);
314 if (__dist.
second >= __gnu_debug::__dp_sign)
315 _Base::insert(__gnu_debug::__unsafe(__first),
316 __gnu_debug::__unsafe(__last));
318 _Base::insert(__first, __last);
321 #if __cplusplus > 201402L
322 using node_type =
typename _Base::node_type;
329 return _Base::extract(__position.
base());
333 extract(
const key_type& __key)
335 const auto __position = find(__key);
336 if (__position != end())
337 return extract(__position);
342 insert(node_type&& __nh)
343 {
return { _Base::insert(
std::move(__nh)),
this }; }
349 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
355 #if __cplusplus >= 201103L
361 return { _Base::erase(__position.
base()),
this };
364 _GLIBCXX_ABI_TAG_CXX11
374 _Base::erase(__position.
base());
379 erase(
const key_type& __x)
382 _Base::equal_range(__x);
383 size_type __count = 0;
385 while (__victim != __victims.
second)
388 _Base::erase(__victim++);
394 #if __cplusplus >= 201103L
402 __victim != __last.
base(); ++__victim)
404 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
405 _M_message(__gnu_debug::__msg_valid_range)
406 ._M_iterator(__first,
"first")
407 ._M_iterator(__last,
"last"));
411 return { _Base::erase(__first.base(), __last.
base()),
this };
421 __victim != __last.
base(); ++__victim)
423 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
424 _M_message(__gnu_debug::__msg_valid_range)
425 ._M_iterator(__first,
"first")
426 ._M_iterator(__last,
"last"));
429 _Base::erase(__first.base(), __last.
base());
435 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
442 clear() _GLIBCXX_NOEXCEPT
444 this->_M_invalidate_all();
449 using _Base::key_comp;
450 using _Base::value_comp;
454 find(
const key_type& __x)
455 {
return iterator(_Base::find(__x),
this); }
457 #if __cplusplus > 201103L
458 template<
typename _Kt,
460 typename __has_is_transparent<_Compare, _Kt>::type>
463 {
return { _Base::find(__x),
this }; }
467 find(
const key_type& __x)
const
470 #if __cplusplus > 201103L
471 template<
typename _Kt,
473 typename __has_is_transparent<_Compare, _Kt>::type>
475 find(
const _Kt& __x)
const
476 {
return { _Base::find(__x),
this }; }
482 lower_bound(
const key_type& __x)
483 {
return iterator(_Base::lower_bound(__x),
this); }
485 #if __cplusplus > 201103L
486 template<
typename _Kt,
488 typename __has_is_transparent<_Compare, _Kt>::type>
490 lower_bound(
const _Kt& __x)
491 {
return { _Base::lower_bound(__x),
this }; }
495 lower_bound(
const key_type& __x)
const
498 #if __cplusplus > 201103L
499 template<
typename _Kt,
501 typename __has_is_transparent<_Compare, _Kt>::type>
503 lower_bound(
const _Kt& __x)
const
504 {
return { _Base::lower_bound(__x),
this }; }
508 upper_bound(
const key_type& __x)
509 {
return iterator(_Base::upper_bound(__x),
this); }
511 #if __cplusplus > 201103L
512 template<
typename _Kt,
514 typename __has_is_transparent<_Compare, _Kt>::type>
516 upper_bound(
const _Kt& __x)
517 {
return { _Base::upper_bound(__x),
this }; }
521 upper_bound(
const key_type& __x)
const
524 #if __cplusplus > 201103L
525 template<
typename _Kt,
527 typename __has_is_transparent<_Compare, _Kt>::type>
529 upper_bound(
const _Kt& __x)
const
530 {
return { _Base::upper_bound(__x),
this }; }
534 equal_range(
const key_type& __x)
537 _Base::equal_range(__x);
542 #if __cplusplus > 201103L
543 template<
typename _Kt,
545 typename __has_is_transparent<_Compare, _Kt>::type>
547 equal_range(
const _Kt& __x)
549 auto __res = _Base::equal_range(__x);
550 return { { __res.first,
this }, { __res.second,
this } };
555 equal_range(
const key_type& __x)
const
558 _Base::equal_range(__x);
563 #if __cplusplus > 201103L
564 template<
typename _Kt,
566 typename __has_is_transparent<_Compare, _Kt>::type>
568 equal_range(
const _Kt& __x)
const
570 auto __res = _Base::equal_range(__x);
571 return { { __res.first,
this }, { __res.second,
this } };
576 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
579 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
582 #if __cpp_deduction_guides >= 201606
584 template<
typename _InputIterator,
587 typename = _RequireInputIter<_InputIterator>,
588 typename = _RequireNotAllocator<_Compare>,
589 typename = _RequireAllocator<_Allocator>>
590 multimap(_InputIterator, _InputIterator,
591 _Compare = _Compare(), _Allocator = _Allocator())
593 _Compare, _Allocator>;
595 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
596 typename _Allocator = allocator<pair<const _Key, _Tp>>,
597 typename = _RequireNotAllocator<_Compare>,
598 typename = _RequireAllocator<_Allocator>>
600 _Compare = _Compare(), _Allocator = _Allocator())
603 template<
typename _InputIterator,
typename _Allocator,
604 typename = _RequireInputIter<_InputIterator>,
605 typename = _RequireAllocator<_Allocator>>
606 multimap(_InputIterator, _InputIterator, _Allocator)
610 template<
typename _Key,
typename _Tp,
typename _Allocator,
611 typename = _RequireAllocator<_Allocator>>
617 template<
typename _Key,
typename _Tp,
618 typename _Compare,
typename _Allocator>
622 {
return __lhs._M_base() == __rhs._M_base(); }
624 #if __cpp_lib_three_way_comparison
625 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
626 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
629 {
return __lhs._M_base() <=> __rhs._M_base(); }
631 template<
typename _Key,
typename _Tp,
632 typename _Compare,
typename _Allocator>
634 operator!=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
635 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
636 {
return __lhs._M_base() != __rhs._M_base(); }
638 template<
typename _Key,
typename _Tp,
639 typename _Compare,
typename _Allocator>
641 operator<(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
642 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
643 {
return __lhs._M_base() < __rhs._M_base(); }
645 template<
typename _Key,
typename _Tp,
646 typename _Compare,
typename _Allocator>
648 operator<=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
649 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
650 {
return __lhs._M_base() <= __rhs._M_base(); }
652 template<
typename _Key,
typename _Tp,
653 typename _Compare,
typename _Allocator>
655 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
656 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
657 {
return __lhs._M_base() >= __rhs._M_base(); }
659 template<
typename _Key,
typename _Tp,
660 typename _Compare,
typename _Allocator>
662 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
663 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
664 {
return __lhs._M_base() > __rhs._M_base(); }
667 template<
typename _Key,
typename _Tp,
668 typename _Compare,
typename _Allocator>
670 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
671 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
672 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
673 { __lhs.swap(__rhs); }
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
Define a member typedef type only if a boolean constant is true.
The standard allocator, as per C++03 [20.4.1].
One of the comparison functors.
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
Struct holding two objects of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.
_Iterator & base() noexcept
Return the underlying iterator.
void _M_invalidate_if(_Predicate __pred)
Class std::multimap with safety/checking/debug instrumentation.
Safe class dealing with some allocator dependent operations.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...