29#ifndef _GLIBCXX_DEBUG_MULTIMAP_H
30#define _GLIBCXX_DEBUG_MULTIMAP_H 1
37namespace 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> > >
45 :
public __gnu_debug::_Safe_container<
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;
52 typedef __gnu_debug::_Safe_container<
53 multimap, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
55 typedef typename _Base::const_iterator _Base_const_iterator;
56 typedef typename _Base::iterator _Base_iterator;
57 typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
59 template<
typename _ItT,
typename _SeqT,
typename _CatT>
60 friend class ::__gnu_debug::_Safe_iterator;
67 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
74 typedef _Key key_type;
75 typedef _Tp mapped_type;
76 typedef std::pair<const _Key, _Tp> value_type;
77 typedef _Compare key_compare;
78 typedef _Allocator allocator_type;
79 typedef typename _Base::reference reference;
80 typedef typename _Base::const_reference const_reference;
82 typedef __gnu_debug::_Safe_iterator<_Base_iterator, multimap>
84 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator,
85 multimap> const_iterator;
87 typedef typename _Base::size_type size_type;
88 typedef typename _Base::difference_type difference_type;
89 typedef typename _Base::pointer pointer;
90 typedef typename _Base::const_pointer const_pointer;
91 typedef std::reverse_iterator<iterator> reverse_iterator;
92 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
96#if __cplusplus < 201103L
97 multimap() : _Base() { }
99 multimap(
const multimap& __x)
104 multimap() =
default;
105 multimap(
const multimap&) =
default;
106 multimap(multimap&&) =
default;
108 multimap(initializer_list<value_type> __l,
109 const _Compare& __c = _Compare(),
110 const allocator_type& __a = allocator_type())
111 : _Base(__l, __c, __a) { }
114 multimap(
const allocator_type& __a)
117 multimap(
const multimap& __m,
118 const __type_identity_t<allocator_type>& __a)
119 : _Base(__m, __a) { }
121 multimap(multimap&& __m,
const __type_identity_t<allocator_type>& __a)
122 noexcept(
noexcept(_Base(
std::move(__m), __a)) )
123 : _Safe(std::
move(__m), __a),
124 _Base(std::
move(__m), __a) { }
126 multimap(initializer_list<value_type> __l,
const allocator_type& __a)
127 : _Base(__l, __a) { }
129 template<
typename _InputIterator>
130 multimap(_InputIterator __first, _InputIterator __last,
131 const allocator_type& __a)
132 : _Base(__gnu_debug::
__base(
133 __glibcxx_check_valid_constructor_range(__first, __last)),
134 __gnu_debug::
__base(__last), __a) { }
136#if __glibcxx_containers_ranges
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
142 multimap(std::from_range_t __t, _Rg&& __rg,
144 const allocator_type& __a = allocator_type())
145 : _Base(__t, std::
forward<_Rg>(__rg), __c, __a)
148 template<std::__detail::__container_compatible_range<value_type> _Rg>
149 multimap(std::from_range_t __t, _Rg&& __rg,
150 const allocator_type& __a = allocator_type())
151 : _Base(__t, std::
forward<_Rg>(__rg), __a)
155 ~multimap() =
default;
158 explicit multimap(
const _Compare& __comp,
159 const _Allocator& __a = _Allocator())
160 : _Base(__comp, __a) { }
162 template<
typename _InputIterator>
163 multimap(_InputIterator __first, _InputIterator __last,
164 const _Compare& __comp = _Compare(),
165 const _Allocator& __a = _Allocator())
166 : _Base(__gnu_debug::
__base(
167 __glibcxx_check_valid_constructor_range(__first, __last)),
168 __gnu_debug::
__base(__last),
171 multimap(_Base_ref __x)
172 : _Base(__x._M_ref) { }
174#if __cplusplus >= 201103L
176 operator=(
const multimap&) =
default;
179 operator=(multimap&&) =
default;
182 operator=(initializer_list<value_type> __l)
184 _Base::operator=(__l);
190 using _Base::get_allocator;
194 begin() _GLIBCXX_NOEXCEPT
195 {
return iterator(_Base::begin(),
this); }
198 begin() const _GLIBCXX_NOEXCEPT
199 {
return const_iterator(_Base::begin(),
this); }
202 end() _GLIBCXX_NOEXCEPT
203 {
return iterator(_Base::end(),
this); }
206 end() const _GLIBCXX_NOEXCEPT
207 {
return const_iterator(_Base::end(),
this); }
210 rbegin() _GLIBCXX_NOEXCEPT
211 {
return reverse_iterator(end()); }
213 const_reverse_iterator
214 rbegin() const _GLIBCXX_NOEXCEPT
215 {
return const_reverse_iterator(end()); }
218 rend() _GLIBCXX_NOEXCEPT
219 {
return reverse_iterator(begin()); }
221 const_reverse_iterator
222 rend() const _GLIBCXX_NOEXCEPT
223 {
return const_reverse_iterator(begin()); }
225#if __cplusplus >= 201103L
227 cbegin() const noexcept
228 {
return const_iterator(_Base::begin(),
this); }
231 cend() const noexcept
232 {
return const_iterator(_Base::end(),
this); }
234 const_reverse_iterator
235 crbegin() const noexcept
236 {
return const_reverse_iterator(end()); }
238 const_reverse_iterator
239 crend() const noexcept
240 {
return const_reverse_iterator(begin()); }
246 using _Base::max_size;
249#if __cplusplus >= 201103L
250 template<
typename... _Args>
252 emplace(_Args&&... __args)
255 template<
typename... _Args>
257 emplace_hint(const_iterator __pos, _Args&&... __args)
269 insert(
const value_type& __x)
270 {
return iterator(_Base::insert(__x),
this); }
272#if __cplusplus >= 201103L
276 insert(value_type&& __x)
277 {
return { _Base::insert(
std::move(__x)),
this }; }
279 template<
typename _Pair,
typename =
typename
280 std::enable_if<std::is_constructible<value_type,
281 _Pair&&>::value>::type>
287#if __cplusplus >= 201103L
289 insert(std::initializer_list<value_type> __list)
290 { _Base::insert(__list); }
294#if __cplusplus >= 201103L
295 insert(const_iterator __position,
const value_type& __x)
297 insert(iterator __position,
const value_type& __x)
301 return iterator(_Base::insert(__position.base(), __x),
this);
304#if __cplusplus >= 201103L
308 insert(const_iterator __position, value_type&& __x)
311 return { _Base::insert(__position.base(),
std::move(__x)),
this };
314 template<
typename _Pair,
typename =
typename
315 std::enable_if<std::is_constructible<value_type,
316 _Pair&&>::value>::type>
318 insert(const_iterator __position, _Pair&& __x)
329 template<
typename _InputIterator>
331 insert(_InputIterator __first, _InputIterator __last)
333 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
334 __glibcxx_check_valid_range2(__first, __last, __dist);
336 if (__dist.second >= __gnu_debug::__dp_sign)
337 _Base::insert(__gnu_debug::__unsafe(__first),
338 __gnu_debug::__unsafe(__last));
340 _Base::insert(__first, __last);
343#if __cplusplus > 201402L
344 using node_type =
typename _Base::node_type;
347 extract(const_iterator __position)
351 return _Base::extract(__position.base());
355 extract(
const key_type& __key)
357 const auto __position = find(__key);
358 if (__position != end())
359 return extract(__position);
364 insert(node_type&& __nh)
365 {
return { _Base::insert(
std::move(__nh)),
this }; }
368 insert(const_iterator __hint, node_type&& __nh)
371 return { _Base::insert(__hint.base(),
std::move(__nh)),
this };
377#if __cplusplus >= 201103L
379 erase(const_iterator __position)
382 return { erase(__position.base()),
this };
386 erase(_Base_const_iterator __position)
388 __glibcxx_check_erase2(__position);
390 return _Base::erase(__position);
393 _GLIBCXX_ABI_TAG_CXX11
395 erase(iterator __position)
396 {
return erase(const_iterator(__position)); }
399 erase(iterator __position)
403 _Base::erase(__position.base());
408 erase(
const key_type& __x)
411 _Base::equal_range(__x);
412 size_type __count = 0;
413 _Base_iterator __victim = __victims.
first;
414 while (__victim != __victims.
second)
417 _Base::erase(__victim++);
423#if __cplusplus >= 201103L
425 erase(const_iterator __first, const_iterator __last)
430 for (_Base_const_iterator __victim = __first.base();
431 __victim != __last.base(); ++__victim)
433 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
434 _M_message(__gnu_debug::__msg_valid_range)
435 ._M_iterator(__first,
"first")
436 ._M_iterator(__last,
"last"));
440 return { _Base::erase(__first.base(), __last.base()),
this };
444 erase(iterator __first, iterator __last)
449 for (_Base_iterator __victim = __first.base();
450 __victim != __last.base(); ++__victim)
452 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
453 _M_message(__gnu_debug::__msg_valid_range)
454 ._M_iterator(__first,
"first")
455 ._M_iterator(__last,
"last"));
458 _Base::erase(__first.base(), __last.base());
471 clear() _GLIBCXX_NOEXCEPT
478 using _Base::key_comp;
479 using _Base::value_comp;
483 find(
const key_type& __x)
484 {
return iterator(_Base::find(__x),
this); }
486#if __cplusplus > 201103L
487 template<
typename _Kt,
489 typename __has_is_transparent<_Compare, _Kt>::type>
492 {
return { _Base::find(__x),
this }; }
496 find(
const key_type& __x)
const
497 {
return const_iterator(_Base::find(__x),
this); }
499#if __cplusplus > 201103L
500 template<
typename _Kt,
502 typename __has_is_transparent<_Compare, _Kt>::type>
504 find(
const _Kt& __x)
const
505 {
return { _Base::find(__x),
this }; }
511 lower_bound(
const key_type& __x)
512 {
return iterator(_Base::lower_bound(__x),
this); }
514#if __cplusplus > 201103L
515 template<
typename _Kt,
517 typename __has_is_transparent<_Compare, _Kt>::type>
519 lower_bound(
const _Kt& __x)
520 {
return { _Base::lower_bound(__x),
this }; }
524 lower_bound(
const key_type& __x)
const
525 {
return const_iterator(_Base::lower_bound(__x),
this); }
527#if __cplusplus > 201103L
528 template<
typename _Kt,
530 typename __has_is_transparent<_Compare, _Kt>::type>
532 lower_bound(
const _Kt& __x)
const
533 {
return { _Base::lower_bound(__x),
this }; }
537 upper_bound(
const key_type& __x)
538 {
return iterator(_Base::upper_bound(__x),
this); }
540#if __cplusplus > 201103L
541 template<
typename _Kt,
543 typename __has_is_transparent<_Compare, _Kt>::type>
545 upper_bound(
const _Kt& __x)
546 {
return { _Base::upper_bound(__x),
this }; }
550 upper_bound(
const key_type& __x)
const
551 {
return const_iterator(_Base::upper_bound(__x),
this); }
553#if __cplusplus > 201103L
554 template<
typename _Kt,
556 typename __has_is_transparent<_Compare, _Kt>::type>
558 upper_bound(
const _Kt& __x)
const
559 {
return { _Base::upper_bound(__x),
this }; }
563 equal_range(
const key_type& __x)
566 _Base::equal_range(__x);
568 iterator(__res.
second,
this));
571#if __cplusplus > 201103L
572 template<
typename _Kt,
574 typename __has_is_transparent<_Compare, _Kt>::type>
576 equal_range(
const _Kt& __x)
578 auto __res = _Base::equal_range(__x);
579 return { { __res.
first,
this }, { __res.
second,
this } };
584 equal_range(
const key_type& __x)
const
587 _Base::equal_range(__x);
589 const_iterator(__res.
second,
this));
592#if __cplusplus > 201103L
593 template<
typename _Kt,
595 typename __has_is_transparent<_Compare, _Kt>::type>
597 equal_range(
const _Kt& __x)
const
599 auto __res = _Base::equal_range(__x);
600 return { { __res.
first,
this }, { __res.
second,
this } };
605 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
608 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
611#if __cpp_deduction_guides >= 201606
613 template<
typename _InputIterator,
614 typename _Compare = less<__iter_key_t<_InputIterator>>,
615 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
616 typename = _RequireInputIter<_InputIterator>,
617 typename = _RequireNotAllocator<_Compare>,
618 typename = _RequireAllocator<_Allocator>>
619 multimap(_InputIterator, _InputIterator,
620 _Compare = _Compare(), _Allocator = _Allocator())
622 _Compare, _Allocator>;
624 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
625 typename _Allocator = allocator<pair<const _Key, _Tp>>,
626 typename = _RequireNotAllocator<_Compare>,
627 typename = _RequireAllocator<_Allocator>>
629 _Compare = _Compare(), _Allocator = _Allocator())
632 template<
typename _InputIterator,
typename _Allocator,
633 typename = _RequireInputIter<_InputIterator>,
634 typename = _RequireAllocator<_Allocator>>
635 multimap(_InputIterator, _InputIterator, _Allocator)
637 less<__iter_key_t<_InputIterator>>, _Allocator>;
639 template<
typename _Key,
typename _Tp,
typename _Allocator,
640 typename = _RequireAllocator<_Allocator>>
644#if __glibcxx_containers_ranges
645 template<ranges::input_range _Rg,
646 __not_allocator_like _Compare = less<__detail::__range_key_type<_Rg>>,
647 __allocator_like _Alloc =
648 std::allocator<__detail::__range_to_alloc_type<_Rg>>>
649 multimap(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
651 __detail::__range_mapped_type<_Rg>,
654 template<ranges::input_range _Rg, __allocator_like _Alloc>
655 multimap(from_range_t, _Rg&&, _Alloc)
657 __detail::__range_mapped_type<_Rg>,
658 less<__detail::__range_key_type<_Rg>>,
663 template<
typename _Key,
typename _Tp,
664 typename _Compare,
typename _Allocator>
668 {
return __lhs._M_base() == __rhs._M_base(); }
670#if __cpp_lib_three_way_comparison
671 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
672 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
675 {
return __lhs._M_base() <=> __rhs._M_base(); }
677 template<
typename _Key,
typename _Tp,
678 typename _Compare,
typename _Allocator>
682 {
return __lhs._M_base() != __rhs._M_base(); }
684 template<
typename _Key,
typename _Tp,
685 typename _Compare,
typename _Allocator>
689 {
return __lhs._M_base() < __rhs._M_base(); }
691 template<
typename _Key,
typename _Tp,
692 typename _Compare,
typename _Allocator>
696 {
return __lhs._M_base() <= __rhs._M_base(); }
698 template<
typename _Key,
typename _Tp,
699 typename _Compare,
typename _Allocator>
703 {
return __lhs._M_base() >= __rhs._M_base(); }
705 template<
typename _Key,
typename _Tp,
706 typename _Compare,
typename _Allocator>
710 {
return __lhs._M_base() > __rhs._M_base(); }
713 template<
typename _Key,
typename _Tp,
714 typename _Compare,
typename _Allocator>
718 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
719 { __lhs.swap(__rhs); }
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
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.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
GNU debug code, replaces standard behavior with debug behavior.
_T1 first
The first member.
_T2 second
The second member.
void _M_invalidate_if(_Predicate __pred)
Class std::multimap with safety/checking/debug instrumentation.
void _M_invalidate_all() const