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;
67 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
74 typedef _Key key_type;
75 typedef _Tp mapped_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;
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;
96 #if __cplusplus < 201103L
109 const _Compare& __c = _Compare(),
110 const allocator_type& __a = allocator_type())
111 :
_Base(__l, __c, __a) { }
118 const __type_identity_t<allocator_type>& __a)
119 :
_Base(__m, __a) { }
127 :
_Base(__l, __a) { }
129 template<
typename _InputIterator>
130 multimap(_InputIterator __first, _InputIterator __last,
131 const allocator_type& __a)
133 __glibcxx_check_valid_constructor_range(__first, __last)),
136 #if __glibcxx_containers_ranges
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
144 const allocator_type& __a = allocator_type())
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())
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())
167 __glibcxx_check_valid_constructor_range(__first, __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);
185 this->_M_invalidate_all();
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)
253 {
return { _Base::emplace(std::forward<_Args>(__args)...),
this }; }
255 template<
typename... _Args>
257 emplace_hint(const_iterator __pos, _Args&&... __args)
262 _Base::emplace_hint(__pos.base(), std::forward<_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
281 _Pair&&>::value>::type>
284 {
return { _Base::insert(std::forward<_Pair>(__x)),
this }; }
287 #if __cplusplus >= 201103L
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
316 _Pair&&>::value>::type>
318 insert(const_iterator __position, _Pair&& __x)
323 _Base::insert(__position.base(), std::forward<_Pair>(__x)),
329 template<
typename _InputIterator>
331 insert(_InputIterator __first, _InputIterator __last)
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 #ifdef __glibcxx_node_extract
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);
363 # ifdef __glibcxx_associative_heterogeneous_erasure
364 template <__heterogeneous_tree_key<multimap> _Kt>
368 const auto __position = find(__key);
369 if (__position != end())
370 return extract(__position);
376 insert(node_type&& __nh)
377 {
return { _Base::insert(
std::move(__nh)),
this }; }
380 insert(const_iterator __hint, node_type&& __nh)
383 return { _Base::insert(__hint.base(),
std::move(__nh)),
this };
389 #if __cplusplus >= 201103L
391 erase(const_iterator __position)
394 return { erase(__position.base()),
this };
398 erase(_Base_const_iterator __position)
400 __glibcxx_check_erase2(__position);
402 return _Base::erase(__position);
405 _GLIBCXX_ABI_TAG_CXX11
407 erase(iterator __position)
408 {
return erase(const_iterator(__position)); }
411 erase(iterator __position)
415 _Base::erase(__position.base());
420 erase(
const key_type& __x)
423 _Base::equal_range(__x);
424 size_type __count = 0;
425 _Base_iterator __victim = __victims.
first;
426 while (__victim != __victims.
second)
429 _Base::erase(__victim++);
435 # ifdef __glibcxx_associative_heterogeneous_erasure
436 template <__heterogeneous_tree_key<multimap> _Kt>
440 auto __victims = _Base::equal_range(__x);
441 size_type __count = 0;
442 for (
auto __victim = __victims.
first; __victim != __victims.
second;)
445 _Base::erase(__victim++);
452 #if __cplusplus >= 201103L
454 erase(const_iterator __first, const_iterator __last)
459 for (_Base_const_iterator __victim = __first.base();
460 __victim != __last.base(); ++__victim)
462 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
463 _M_message(__gnu_debug::__msg_valid_range)
464 ._M_iterator(__first,
"first")
465 ._M_iterator(__last,
"last"));
469 return { _Base::erase(__first.base(), __last.base()),
this };
473 erase(iterator __first, iterator __last)
478 for (_Base_iterator __victim = __first.base();
479 __victim != __last.base(); ++__victim)
481 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
482 _M_message(__gnu_debug::__msg_valid_range)
483 ._M_iterator(__first,
"first")
484 ._M_iterator(__last,
"last"));
487 _Base::erase(__first.base(), __last.base());
493 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
500 clear() _GLIBCXX_NOEXCEPT
502 this->_M_invalidate_all();
507 using _Base::key_comp;
508 using _Base::value_comp;
512 find(
const key_type& __x)
513 {
return iterator(_Base::find(__x),
this); }
515 #ifdef __glibcxx_generic_associative_lookup
516 template<
typename _Kt,
518 typename __has_is_transparent<_Compare, _Kt>::type>
521 {
return { _Base::find(__x),
this }; }
525 find(
const key_type& __x)
const
526 {
return const_iterator(_Base::find(__x),
this); }
528 #ifdef __glibcxx_generic_associative_lookup
529 template<
typename _Kt,
531 typename __has_is_transparent<_Compare, _Kt>::type>
533 find(
const _Kt& __x)
const
534 {
return { _Base::find(__x),
this }; }
540 lower_bound(
const key_type& __x)
541 {
return iterator(_Base::lower_bound(__x),
this); }
543 #ifdef __glibcxx_generic_associative_lookup
544 template<
typename _Kt,
546 typename __has_is_transparent<_Compare, _Kt>::type>
548 lower_bound(
const _Kt& __x)
549 {
return { _Base::lower_bound(__x),
this }; }
553 lower_bound(
const key_type& __x)
const
554 {
return const_iterator(_Base::lower_bound(__x),
this); }
556 #ifdef __glibcxx_generic_associative_lookup
557 template<
typename _Kt,
559 typename __has_is_transparent<_Compare, _Kt>::type>
561 lower_bound(
const _Kt& __x)
const
562 {
return { _Base::lower_bound(__x),
this }; }
566 upper_bound(
const key_type& __x)
567 {
return iterator(_Base::upper_bound(__x),
this); }
569 #ifdef __glibcxx_generic_associative_lookup
570 template<
typename _Kt,
572 typename __has_is_transparent<_Compare, _Kt>::type>
574 upper_bound(
const _Kt& __x)
575 {
return { _Base::upper_bound(__x),
this }; }
579 upper_bound(
const key_type& __x)
const
580 {
return const_iterator(_Base::upper_bound(__x),
this); }
582 #ifdef __glibcxx_generic_associative_lookup
583 template<
typename _Kt,
585 typename __has_is_transparent<_Compare, _Kt>::type>
587 upper_bound(
const _Kt& __x)
const
588 {
return { _Base::upper_bound(__x),
this }; }
592 equal_range(
const key_type& __x)
595 _Base::equal_range(__x);
596 return std::make_pair(iterator(__res.
first,
this),
597 iterator(__res.
second,
this));
600 #ifdef __glibcxx_generic_associative_lookup
601 template<
typename _Kt,
603 typename __has_is_transparent<_Compare, _Kt>::type>
605 equal_range(
const _Kt& __x)
607 auto __res = _Base::equal_range(__x);
608 return { { __res.
first,
this }, { __res.
second,
this } };
613 equal_range(
const key_type& __x)
const
616 _Base::equal_range(__x);
617 return std::make_pair(const_iterator(__res.
first,
this),
618 const_iterator(__res.
second,
this));
621 #ifdef __glibcxx_generic_associative_lookup
622 template<
typename _Kt,
624 typename __has_is_transparent<_Compare, _Kt>::type>
626 equal_range(
const _Kt& __x)
const
628 auto __res = _Base::equal_range(__x);
629 return { { __res.
first,
this }, { __res.
second,
this } };
634 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
637 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
640 #if __cpp_deduction_guides >= 201606
642 template<
typename _InputIterator,
643 typename _Compare = less<__iter_key_t<_InputIterator>>,
644 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
645 typename = _RequireInputIter<_InputIterator>,
646 typename = _RequireNotAllocator<_Compare>,
647 typename = _RequireAllocator<_Allocator>>
648 multimap(_InputIterator, _InputIterator,
649 _Compare = _Compare(), _Allocator = _Allocator())
650 -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
651 _Compare, _Allocator>;
653 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
654 typename _Allocator = allocator<pair<const _Key, _Tp>>,
655 typename = _RequireNotAllocator<_Compare>,
656 typename = _RequireAllocator<_Allocator>>
657 multimap(initializer_list<pair<_Key, _Tp>>,
658 _Compare = _Compare(), _Allocator = _Allocator())
659 -> multimap<_Key, _Tp, _Compare, _Allocator>;
661 template<
typename _InputIterator,
typename _Allocator,
662 typename = _RequireInputIter<_InputIterator>,
663 typename = _RequireAllocator<_Allocator>>
664 multimap(_InputIterator, _InputIterator, _Allocator)
665 -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
666 less<__iter_key_t<_InputIterator>>, _Allocator>;
668 template<
typename _Key,
typename _Tp,
typename _Allocator,
669 typename = _RequireAllocator<_Allocator>>
670 multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
671 -> multimap<_Key, _Tp, less<_Key>, _Allocator>;
673 #if __glibcxx_containers_ranges
674 template<ranges::input_range _Rg,
675 __not_allocator_like _Compare = less<__detail::__range_key_type<_Rg>>,
676 __allocator_like _Alloc =
678 multimap(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
679 -> multimap<__detail::__range_key_type<_Rg>,
680 __detail::__range_mapped_type<_Rg>,
683 template<ranges::input_range _Rg, __allocator_like _Alloc>
684 multimap(from_range_t, _Rg&&, _Alloc)
685 -> multimap<__detail::__range_key_type<_Rg>,
686 __detail::__range_mapped_type<_Rg>,
687 less<__detail::__range_key_type<_Rg>>,
692 template<
typename _Key,
typename _Tp,
693 typename _Compare,
typename _Allocator>
695 operator==(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
696 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
697 {
return __lhs._M_base() == __rhs._M_base(); }
699 #if __cpp_lib_three_way_comparison
700 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
701 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
702 operator<=>(
const multimap<_Key, _Tp, _Compare, _Alloc>& __lhs,
703 const multimap<_Key, _Tp, _Compare, _Alloc>& __rhs)
704 {
return __lhs._M_base() <=> __rhs._M_base(); }
706 template<
typename _Key,
typename _Tp,
707 typename _Compare,
typename _Allocator>
709 operator!=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
710 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
711 {
return __lhs._M_base() != __rhs._M_base(); }
713 template<
typename _Key,
typename _Tp,
714 typename _Compare,
typename _Allocator>
716 operator<(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
717 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
718 {
return __lhs._M_base() < __rhs._M_base(); }
720 template<
typename _Key,
typename _Tp,
721 typename _Compare,
typename _Allocator>
723 operator<=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
724 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
725 {
return __lhs._M_base() <= __rhs._M_base(); }
727 template<
typename _Key,
typename _Tp,
728 typename _Compare,
typename _Allocator>
730 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
731 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
732 {
return __lhs._M_base() >= __rhs._M_base(); }
734 template<
typename _Key,
typename _Tp,
735 typename _Compare,
typename _Allocator>
737 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
738 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
739 {
return __lhs._M_base() > __rhs._M_base(); }
742 template<
typename _Key,
typename _Tp,
743 typename _Compare,
typename _Allocator>
745 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
746 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
747 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
748 { __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)
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.
GNU debug classes for public use.
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].
Struct holding two objects (or references) of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
constexpr void _M_invalidate_if(_Predicate __pred) const
Class std::multimap with safety/checking/debug instrumentation.
multimap(std::from_range_t __t, _Rg &&__rg, const _Compare &__c, const allocator_type &__a=allocator_type())
Construct a multimap from a range.
Safe class dealing with some allocator dependent operations.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...