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 :
_Safe(std::move(__m._M_safe()), __a),
109 _Base(std::move(__m._M_base()), __a) { }
112 :
_Base(__l, __a) { }
114 template<
typename _InputIterator>
115 multimap(_InputIterator __first, _InputIterator __last,
116 const allocator_type& __a)
117 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
119 __gnu_debug::__base(__last), __a) { }
124 explicit multimap(
const _Compare& __comp,
125 const _Allocator& __a = _Allocator())
126 :
_Base(__comp, __a) { }
128 template<
typename _InputIterator>
129 multimap(_InputIterator __first, _InputIterator __last,
130 const _Compare& __comp = _Compare(),
131 const _Allocator& __a = _Allocator())
132 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
134 __gnu_debug::__base(__last),
140 #if __cplusplus < 201103L 144 this->_M_safe() = __x;
150 operator=(
const multimap&) =
default;
159 this->_M_invalidate_all();
164 using _Base::get_allocator;
168 begin() _GLIBCXX_NOEXCEPT
169 {
return iterator(_Base::begin(),
this); }
172 begin()
const _GLIBCXX_NOEXCEPT
176 end() _GLIBCXX_NOEXCEPT
177 {
return iterator(_Base::end(),
this); }
180 end()
const _GLIBCXX_NOEXCEPT
184 rbegin() _GLIBCXX_NOEXCEPT
188 rbegin()
const _GLIBCXX_NOEXCEPT
192 rend() _GLIBCXX_NOEXCEPT
196 rend()
const _GLIBCXX_NOEXCEPT
199 #if __cplusplus >= 201103L 201 cbegin()
const noexcept
205 cend()
const noexcept
209 crbegin()
const noexcept
213 crend()
const noexcept
220 using _Base::max_size;
223 #if __cplusplus >= 201103L 224 template<
typename... _Args>
226 emplace(_Args&&... __args)
228 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
231 template<
typename... _Args>
237 std::forward<_Args>(__args)...),
244 {
return iterator(_Base::insert(__x),
this); }
246 #if __cplusplus >= 201103L 251 {
return { _Base::insert(std::move(__x)),
this }; }
253 template<
typename _Pair,
typename =
typename 255 _Pair&&>::value>::type>
258 {
return iterator(_Base::insert(std::forward<_Pair>(__x)),
this); }
261 #if __cplusplus >= 201103L 264 { _Base::insert(__list); }
268 #if __cplusplus >= 201103L 275 return iterator(_Base::insert(__position.
base(), __x),
this);
278 #if __cplusplus >= 201103L 285 return { _Base::insert(__position.
base(), std::move(__x)),
this };
288 template<
typename _Pair,
typename =
typename 290 _Pair&&>::value>::type>
296 std::forward<_Pair>(__x)),
this);
300 template<
typename _InputIterator>
302 insert(_InputIterator __first, _InputIterator __last)
305 __glibcxx_check_valid_range2(__first, __last, __dist);
307 if (__dist.
second >= __gnu_debug::__dp_sign)
308 _Base::insert(__gnu_debug::__unsafe(__first),
309 __gnu_debug::__unsafe(__last));
311 _Base::insert(__first, __last);
314 #if __cplusplus > 201402L 315 using node_type =
typename _Base::node_type;
322 return _Base::extract(__position.
base());
326 extract(
const key_type& __key)
328 const auto __position = find(__key);
329 if (__position != end())
330 return extract(__position);
335 insert(node_type&& __nh)
336 {
return iterator(_Base::insert(std::move(__nh)),
this); }
342 return iterator(_Base::insert(__hint.
base(), std::move(__nh)),
this);
348 #if __cplusplus >= 201103L 366 _Base::erase(__position.
base());
371 erase(
const key_type& __x)
374 _Base::equal_range(__x);
375 size_type __count = 0;
377 while (__victim != __victims.
second)
380 _Base::erase(__victim++);
386 #if __cplusplus >= 201103L 394 __victim != __last.
base(); ++__victim)
396 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
397 _M_message(__gnu_debug::__msg_valid_range)
398 ._M_iterator(__first,
"first")
399 ._M_iterator(__last,
"last"));
412 __victim != __last.
base(); ++__victim)
414 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
415 _M_message(__gnu_debug::__msg_valid_range)
416 ._M_iterator(__first,
"first")
417 ._M_iterator(__last,
"last"));
420 _Base::erase(__first.
base(), __last.
base());
426 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
433 clear() _GLIBCXX_NOEXCEPT
435 this->_M_invalidate_all();
440 using _Base::key_comp;
441 using _Base::value_comp;
445 find(
const key_type& __x)
446 {
return iterator(_Base::find(__x),
this); }
448 #if __cplusplus > 201103L 449 template<
typename _Kt,
451 typename __has_is_transparent<_Compare, _Kt>::type>
454 {
return { _Base::find(__x),
this }; }
458 find(
const key_type& __x)
const 461 #if __cplusplus > 201103L 462 template<
typename _Kt,
464 typename __has_is_transparent<_Compare, _Kt>::type>
466 find(
const _Kt& __x)
const 467 {
return { _Base::find(__x),
this }; }
473 lower_bound(
const key_type& __x)
474 {
return iterator(_Base::lower_bound(__x),
this); }
476 #if __cplusplus > 201103L 477 template<
typename _Kt,
479 typename __has_is_transparent<_Compare, _Kt>::type>
481 lower_bound(
const _Kt& __x)
482 {
return { _Base::lower_bound(__x),
this }; }
486 lower_bound(
const key_type& __x)
const 489 #if __cplusplus > 201103L 490 template<
typename _Kt,
492 typename __has_is_transparent<_Compare, _Kt>::type>
494 lower_bound(
const _Kt& __x)
const 495 {
return { _Base::lower_bound(__x),
this }; }
499 upper_bound(
const key_type& __x)
500 {
return iterator(_Base::upper_bound(__x),
this); }
502 #if __cplusplus > 201103L 503 template<
typename _Kt,
505 typename __has_is_transparent<_Compare, _Kt>::type>
507 upper_bound(
const _Kt& __x)
508 {
return { _Base::upper_bound(__x),
this }; }
512 upper_bound(
const key_type& __x)
const 515 #if __cplusplus > 201103L 516 template<
typename _Kt,
518 typename __has_is_transparent<_Compare, _Kt>::type>
520 upper_bound(
const _Kt& __x)
const 521 {
return { _Base::upper_bound(__x),
this }; }
525 equal_range(
const key_type& __x)
528 _Base::equal_range(__x);
533 #if __cplusplus > 201103L 534 template<
typename _Kt,
536 typename __has_is_transparent<_Compare, _Kt>::type>
538 equal_range(
const _Kt& __x)
540 auto __res = _Base::equal_range(__x);
541 return { { __res.first,
this }, { __res.second,
this } };
546 equal_range(
const key_type& __x)
const 549 _Base::equal_range(__x);
554 #if __cplusplus > 201103L 555 template<
typename _Kt,
557 typename __has_is_transparent<_Compare, _Kt>::type>
559 equal_range(
const _Kt& __x)
const 561 auto __res = _Base::equal_range(__x);
562 return { { __res.first,
this }, { __res.second,
this } };
567 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
570 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
573 #if __cpp_deduction_guides >= 201606 575 template<
typename _InputIterator,
578 typename = _RequireInputIter<_InputIterator>,
579 typename = _RequireAllocator<_Allocator>>
580 multimap(_InputIterator, _InputIterator,
581 _Compare = _Compare(), _Allocator = _Allocator())
583 _Compare, _Allocator>;
585 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
586 typename _Allocator = allocator<pair<const _Key, _Tp>>,
587 typename = _RequireAllocator<_Allocator>>
589 _Compare = _Compare(), _Allocator = _Allocator())
592 template<
typename _InputIterator,
typename _Allocator,
593 typename = _RequireInputIter<_InputIterator>,
594 typename = _RequireAllocator<_Allocator>>
595 multimap(_InputIterator, _InputIterator, _Allocator)
599 template<
typename _Key,
typename _Tp,
typename _Allocator,
600 typename = _RequireAllocator<_Allocator>>
606 template<
typename _Key,
typename _Tp,
607 typename _Compare,
typename _Allocator>
611 {
return __lhs._M_base() == __rhs._M_base(); }
613 template<
typename _Key,
typename _Tp,
614 typename _Compare,
typename _Allocator>
618 {
return __lhs._M_base() != __rhs._M_base(); }
620 template<
typename _Key,
typename _Tp,
621 typename _Compare,
typename _Allocator>
623 operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
624 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
625 {
return __lhs._M_base() < __rhs._M_base(); }
627 template<
typename _Key,
typename _Tp,
628 typename _Compare,
typename _Allocator>
630 operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
631 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
632 {
return __lhs._M_base() <= __rhs._M_base(); }
634 template<
typename _Key,
typename _Tp,
635 typename _Compare,
typename _Allocator>
637 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
638 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
639 {
return __lhs._M_base() >= __rhs._M_base(); }
641 template<
typename _Key,
typename _Tp,
642 typename _Compare,
typename _Allocator>
644 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
645 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
646 {
return __lhs._M_base() > __rhs._M_base(); }
648 template<
typename _Key,
typename _Tp,
649 typename _Compare,
typename _Allocator>
651 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
652 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
653 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
654 { __lhs.swap(__rhs); }
Class std::multimap with safety/checking/debug instrumentation.
Define a member typedef type only if a boolean constant is true.
#define __glibcxx_check_erase_range(_First, _Last)
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.
_T2 second
first is a copy of the first object
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
_T1 first
second_type is the second bound type
_Iterator & base() noexcept
Return the underlying iterator.
One of the comparison functors.
ISO C++ entities toplevel namespace is std.
The standard allocator, as per [20.4].
void _M_invalidate_if(_Predicate __pred)
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
Safe class dealing with some allocator dependent operations.
#define __glibcxx_check_erase(_Position)
Struct holding two objects of arbitrary type.
#define __glibcxx_check_insert(_Position)