29 #ifndef _GLIBCXX_DEBUG_UNORDERED_MAP 30 #define _GLIBCXX_DEBUG_UNORDERED_MAP 1 32 #pragma GCC system_header 34 #if __cplusplus < 201103L 38 namespace std _GLIBCXX_VISIBILITY(default) {
namespace __debug {
39 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred,
42 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred,
54 namespace std _GLIBCXX_VISIBILITY(default)
59 template<
typename _Key,
typename _Tp,
65 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>, _Alloc,
66 __gnu_debug::_Safe_unordered_container>,
67 public _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
69 typedef _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash,
73 typedef typename _Base::const_iterator _Base_const_iterator;
74 typedef typename _Base::iterator _Base_iterator;
75 typedef typename _Base::const_local_iterator
76 _Base_const_local_iterator;
77 typedef typename _Base::local_iterator _Base_local_iterator;
79 template<
typename _ItT,
typename _SeqT,
typename _CatT>
80 friend class ::__gnu_debug::_Safe_iterator;
81 template<
typename _ItT,
typename _SeqT>
82 friend class ::__gnu_debug::_Safe_local_iterator;
85 typedef typename _Base::size_type size_type;
86 typedef typename _Base::hasher hasher;
87 typedef typename _Base::key_equal key_equal;
88 typedef typename _Base::allocator_type allocator_type;
90 typedef typename _Base::key_type key_type;
91 typedef typename _Base::value_type value_type;
94 _Base_iterator, unordered_map>
iterator;
102 unordered_map() =
default;
105 unordered_map(size_type __n,
106 const hasher& __hf = hasher(),
107 const key_equal& __eql = key_equal(),
108 const allocator_type& __a = allocator_type())
109 : _Base(__n, __hf, __eql, __a) { }
111 template<
typename _InputIterator>
112 unordered_map(_InputIterator __first, _InputIterator __last,
114 const hasher& __hf = hasher(),
115 const key_equal& __eql = key_equal(),
116 const allocator_type& __a = allocator_type())
118 __glibcxx_check_valid_constructor_range(__first, __last)),
120 __hf, __eql, __a) { }
122 unordered_map(
const unordered_map&) =
default;
124 unordered_map(
const _Base& __x)
127 unordered_map(unordered_map&&) =
default;
130 unordered_map(
const allocator_type& __a)
133 unordered_map(
const unordered_map& __umap,
134 const allocator_type& __a)
135 : _Base(__umap, __a) { }
137 unordered_map(unordered_map&& __umap,
138 const allocator_type& __a)
139 : _Safe(
std::move(__umap._M_safe()), __a),
140 _Base(
std::move(__umap._M_base()), __a) { }
144 const hasher& __hf = hasher(),
145 const key_equal& __eql = key_equal(),
146 const allocator_type& __a = allocator_type())
147 : _Base(__l, __n, __hf, __eql, __a) { }
149 unordered_map(size_type __n,
const allocator_type& __a)
150 : unordered_map(__n, hasher(), key_equal(), __a)
153 unordered_map(size_type __n,
155 const allocator_type& __a)
156 : unordered_map(__n, __hf, key_equal(), __a)
159 template<
typename _InputIterator>
160 unordered_map(_InputIterator __first, _InputIterator __last,
162 const allocator_type& __a)
163 : unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
166 template<
typename _InputIterator>
167 unordered_map(_InputIterator __first, _InputIterator __last,
170 const allocator_type& __a)
171 : unordered_map(__first, __last, __n, __hf, key_equal(), __a)
176 const allocator_type& __a)
177 : unordered_map(__l, __n, hasher(), key_equal(), __a)
183 const allocator_type& __a)
184 : unordered_map(__l, __n, __hf, key_equal(), __a)
187 ~unordered_map() =
default;
190 operator=(
const unordered_map&) =
default;
193 operator=(unordered_map&&) =
default;
199 this->_M_invalidate_all();
204 swap(unordered_map& __x)
205 noexcept( noexcept(declval<_Base&>().swap(__x)) )
215 this->_M_invalidate_all();
223 begin() const noexcept
239 cend() const noexcept
246 __glibcxx_check_bucket_index(__b);
253 __glibcxx_check_bucket_index(__b);
258 begin(size_type __b)
const 260 __glibcxx_check_bucket_index(__b);
265 end(size_type __b)
const 267 __glibcxx_check_bucket_index(__b);
272 cbegin(size_type __b)
const 274 __glibcxx_check_bucket_index(__b);
279 cend(size_type __b)
const 281 __glibcxx_check_bucket_index(__b);
286 bucket_size(size_type __b)
const 288 __glibcxx_check_bucket_index(__b);
289 return _Base::bucket_size(__b);
293 max_load_factor() const noexcept
294 {
return _Base::max_load_factor(); }
297 max_load_factor(
float __f)
299 __glibcxx_check_max_load_factor(__f);
300 _Base::max_load_factor(__f);
303 template<
typename... _Args>
305 emplace(_Args&&... __args)
307 size_type __bucket_count = this->bucket_count();
308 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
309 _M_check_rehashed(__bucket_count);
310 return { { __res.first,
this }, __res.second };
313 template<
typename... _Args>
315 emplace_hint(const_iterator __hint, _Args&&... __args)
318 size_type __bucket_count = this->bucket_count();
319 auto __it = _Base::emplace_hint(__hint.
base(),
320 std::forward<_Args>(__args)...);
321 _M_check_rehashed(__bucket_count);
322 return { __it,
this };
326 insert(
const value_type& __obj)
328 size_type __bucket_count = this->bucket_count();
329 auto __res = _Base::insert(__obj);
330 _M_check_rehashed(__bucket_count);
331 return { { __res.first,
this }, __res.second };
337 insert(value_type&& __x)
339 size_type __bucket_count = this->bucket_count();
340 auto __res = _Base::insert(std::move(__x));
341 _M_check_rehashed(__bucket_count);
342 return { { __res.first,
this }, __res.second };
345 template<
typename _Pair,
typename =
typename 347 _Pair&&>::value>::type>
349 insert(_Pair&& __obj)
351 size_type __bucket_count = this->bucket_count();
352 auto __res = _Base::insert(std::forward<_Pair>(__obj));
353 _M_check_rehashed(__bucket_count);
354 return { { __res.first,
this }, __res.second };
358 insert(const_iterator __hint,
const value_type& __obj)
361 size_type __bucket_count = this->bucket_count();
362 auto __it = _Base::insert(__hint.
base(), __obj);
363 _M_check_rehashed(__bucket_count);
364 return { __it,
this };
370 insert(const_iterator __hint, value_type&& __x)
373 size_type __bucket_count = this->bucket_count();
374 auto __it = _Base::insert(__hint.
base(), std::move(__x));
375 _M_check_rehashed(__bucket_count);
376 return { __it,
this };
379 template<
typename _Pair,
typename =
typename 381 _Pair&&>::value>::type>
383 insert(const_iterator __hint, _Pair&& __obj)
386 size_type __bucket_count = this->bucket_count();
387 auto __it = _Base::insert(__hint.
base(), std::forward<_Pair>(__obj));
388 _M_check_rehashed(__bucket_count);
389 return { __it,
this };
395 size_type __bucket_count = this->bucket_count();
397 _M_check_rehashed(__bucket_count);
400 template<
typename _InputIterator>
402 insert(_InputIterator __first, _InputIterator __last)
405 __glibcxx_check_valid_range2(__first, __last, __dist);
406 size_type __bucket_count = this->bucket_count();
408 if (__dist.
second >= __gnu_debug::__dp_sign)
409 _Base::insert(__gnu_debug::__unsafe(__first),
410 __gnu_debug::__unsafe(__last));
412 _Base::insert(__first, __last);
414 _M_check_rehashed(__bucket_count);
417 #if __cplusplus > 201402L 418 template <
typename... _Args>
420 try_emplace(
const key_type& __k, _Args&&... __args)
422 auto __res = _Base::try_emplace(__k,
423 std::forward<_Args>(__args)...);
424 return { { __res.first,
this }, __res.second };
427 template <
typename... _Args>
429 try_emplace(key_type&& __k, _Args&&... __args)
431 auto __res = _Base::try_emplace(std::move(__k),
432 std::forward<_Args>(__args)...);
433 return { { __res.first,
this }, __res.second };
436 template <
typename... _Args>
438 try_emplace(const_iterator __hint,
const key_type& __k,
442 return { _Base::try_emplace(__hint.
base(), __k,
443 std::forward<_Args>(__args)...),
447 template <
typename... _Args>
449 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
452 return { _Base::try_emplace(__hint.
base(), std::move(__k),
453 std::forward<_Args>(__args)...),
457 template <
typename _Obj>
459 insert_or_assign(
const key_type& __k, _Obj&& __obj)
461 auto __res = _Base::insert_or_assign(__k,
462 std::forward<_Obj>(__obj));
463 return { { __res.first,
this }, __res.second };
466 template <
typename _Obj>
468 insert_or_assign(key_type&& __k, _Obj&& __obj)
470 auto __res = _Base::insert_or_assign(std::move(__k),
471 std::forward<_Obj>(__obj));
472 return { { __res.first,
this }, __res.second };
475 template <
typename _Obj>
477 insert_or_assign(const_iterator __hint,
const key_type& __k,
481 return { _Base::insert_or_assign(__hint.
base(), __k,
482 std::forward<_Obj>(__obj)),
486 template <
typename _Obj>
488 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
491 return { _Base::insert_or_assign(__hint.
base(), std::move(__k),
492 std::forward<_Obj>(__obj)),
497 #if __cplusplus > 201402L 498 using node_type =
typename _Base::node_type;
499 using insert_return_type = _Node_insert_return<iterator, node_type>;
502 extract(const_iterator __position)
505 return _M_extract(__position.
base());
509 extract(
const key_type& __key)
511 const auto __position = _Base::find(__key);
513 return _M_extract(__position);
518 insert(node_type&& __nh)
520 auto __ret = _Base::insert(std::move(__nh));
522 { { __ret.position,
this }, __ret.inserted, std::move(__ret.node) };
526 insert(const_iterator __hint, node_type&& __nh)
529 return { _Base::insert(__hint.
base(), std::move(__nh)),
this };
536 find(
const key_type& __key)
537 {
return { _Base::find(__key),
this }; }
540 find(
const key_type& __key)
const 541 {
return { _Base::find(__key),
this }; }
544 equal_range(
const key_type& __key)
546 auto __res = _Base::equal_range(__key);
547 return { { __res.first,
this }, { __res.second,
this } };
551 equal_range(
const key_type& __key)
const 553 auto __res = _Base::equal_range(__key);
554 return { { __res.first,
this }, { __res.second,
this } };
558 erase(
const key_type& __key)
561 auto __victim = _Base::find(__key);
571 erase(const_iterator __it)
574 return { _M_erase(__it.
base()),
this };
581 return { _M_erase(__it.
base()),
this };
585 erase(const_iterator __first, const_iterator __last)
588 for (
auto __tmp = __first.
base(); __tmp != __last.
base(); ++__tmp)
591 _M_message(__gnu_debug::__msg_valid_range)
592 ._M_iterator(__first,
"first")
593 ._M_iterator(__last,
"last"));
594 _M_invalidate(__tmp);
597 size_type __bucket_count = this->bucket_count();
598 auto __next = _Base::erase(__first.
base(), __last.
base());
599 _M_check_rehashed(__bucket_count);
600 return { __next,
this };
604 _M_base() noexcept {
return *
this; }
607 _M_base() const noexcept {
return *
this; }
611 _M_check_rehashed(size_type __prev_count)
613 if (__prev_count != this->bucket_count())
614 this->_M_invalidate_locals();
618 _M_invalidate(_Base_const_iterator __victim)
620 this->_M_invalidate_if(
621 [__victim](_Base_const_iterator __it) {
return __it == __victim; });
622 this->_M_invalidate_local_if(
623 [__victim](_Base_const_local_iterator __it)
624 {
return __it._M_curr() == __victim._M_cur; });
628 _M_erase(_Base_const_iterator __victim)
630 _M_invalidate(__victim);
631 size_type __bucket_count = this->bucket_count();
632 _Base_iterator __next = _Base::erase(__victim);
633 _M_check_rehashed(__bucket_count);
637 #if __cplusplus > 201402L 639 _M_extract(_Base_const_iterator __victim)
641 _M_invalidate(__victim);
642 return _Base::extract(__victim);
647 #if __cpp_deduction_guides >= 201606 649 template<
typename _InputIterator,
653 typename = _RequireInputIter<_InputIterator>,
654 typename = _RequireAllocator<_Allocator>>
655 unordered_map(_InputIterator, _InputIterator,
656 typename unordered_map<int, int>::size_type = {},
657 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
658 -> unordered_map<__iter_key_t<_InputIterator>,
659 __iter_val_t<_InputIterator>,
660 _Hash, _Pred, _Allocator>;
662 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
663 typename _Pred = equal_to<_Key>,
664 typename _Allocator = allocator<pair<const _Key, _Tp>>,
665 typename = _RequireAllocator<_Allocator>>
667 typename unordered_map<int, int>::size_type = {},
668 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
671 template<
typename _InputIterator,
typename _Allocator,
672 typename = _RequireInputIter<_InputIterator>,
673 typename = _RequireAllocator<_Allocator>>
674 unordered_map(_InputIterator, _InputIterator,
675 typename unordered_map<int, int>::size_type, _Allocator)
677 __iter_val_t<_InputIterator>,
682 template<
typename _InputIterator,
typename _Allocator,
683 typename = _RequireInputIter<_InputIterator>,
684 typename = _RequireAllocator<_Allocator>>
685 unordered_map(_InputIterator, _InputIterator, _Allocator)
687 __iter_val_t<_InputIterator>,
688 hash<__iter_key_t<_InputIterator>>,
689 equal_to<__iter_key_t<_InputIterator>>,
692 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
693 typename = _RequireInputIter<_InputIterator>,
694 typename = _RequireAllocator<_Allocator>>
695 unordered_map(_InputIterator, _InputIterator,
696 typename unordered_map<int, int>::size_type,
699 __iter_val_t<_InputIterator>, _Hash,
700 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
702 template<
typename _Key,
typename _Tp,
typename _Allocator,
703 typename = _RequireAllocator<_Allocator>>
705 typename unordered_map<int, int>::size_type,
709 template<
typename _Key,
typename _Tp,
typename _Allocator,
710 typename = _RequireAllocator<_Allocator>>
714 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
715 typename = _RequireAllocator<_Allocator>>
717 typename unordered_map<int, int>::size_type,
723 template<
typename _Key,
typename _Tp,
typename _Hash,
724 typename _Pred,
typename _Alloc>
728 noexcept(noexcept(__x.swap(__y)))
731 template<
typename _Key,
typename _Tp,
typename _Hash,
732 typename _Pred,
typename _Alloc>
736 {
return __x._M_base() == __y._M_base(); }
738 template<
typename _Key,
typename _Tp,
typename _Hash,
739 typename _Pred,
typename _Alloc>
743 {
return !(__x == __y); }
747 template<
typename _Key,
typename _Tp,
753 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>, _Alloc,
754 __gnu_debug::_Safe_unordered_container>,
755 public _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
757 typedef _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash,
758 _Pred, _Alloc> _Base;
761 typedef typename _Base::const_iterator _Base_const_iterator;
762 typedef typename _Base::iterator _Base_iterator;
763 typedef typename _Base::const_local_iterator _Base_const_local_iterator;
764 typedef typename _Base::local_iterator _Base_local_iterator;
766 template<
typename _ItT,
typename _SeqT,
typename _CatT>
767 friend class ::__gnu_debug::_Safe_iterator;
768 template<
typename _ItT,
typename _SeqT>
769 friend class ::__gnu_debug::_Safe_local_iterator;
772 typedef typename _Base::size_type size_type;
773 typedef typename _Base::hasher hasher;
774 typedef typename _Base::key_equal key_equal;
775 typedef typename _Base::allocator_type allocator_type;
777 typedef typename _Base::key_type key_type;
778 typedef typename _Base::value_type value_type;
781 _Base_iterator, unordered_multimap> iterator;
783 _Base_const_iterator, unordered_multimap> const_iterator;
785 _Base_local_iterator, unordered_multimap> local_iterator;
787 _Base_const_local_iterator, unordered_multimap> const_local_iterator;
789 unordered_multimap() =
default;
792 unordered_multimap(size_type __n,
793 const hasher& __hf = hasher(),
794 const key_equal& __eql = key_equal(),
795 const allocator_type& __a = allocator_type())
796 : _Base(__n, __hf, __eql, __a) { }
798 template<
typename _InputIterator>
799 unordered_multimap(_InputIterator __first, _InputIterator __last,
801 const hasher& __hf = hasher(),
802 const key_equal& __eql = key_equal(),
803 const allocator_type& __a = allocator_type())
805 __glibcxx_check_valid_constructor_range(__first, __last)),
807 __hf, __eql, __a) { }
809 unordered_multimap(
const unordered_multimap&) =
default;
811 unordered_multimap(
const _Base& __x)
814 unordered_multimap(unordered_multimap&&) =
default;
817 unordered_multimap(
const allocator_type& __a)
820 unordered_multimap(
const unordered_multimap& __umap,
821 const allocator_type& __a)
822 : _Base(__umap, __a) { }
824 unordered_multimap(unordered_multimap&& __umap,
825 const allocator_type& __a)
826 : _Safe(
std::move(__umap._M_safe()), __a),
827 _Base(
std::move(__umap._M_base()), __a) { }
831 const hasher& __hf = hasher(),
832 const key_equal& __eql = key_equal(),
833 const allocator_type& __a = allocator_type())
834 : _Base(__l, __n, __hf, __eql, __a) { }
836 unordered_multimap(size_type __n,
const allocator_type& __a)
837 : unordered_multimap(__n, hasher(), key_equal(), __a)
840 unordered_multimap(size_type __n,
const hasher& __hf,
841 const allocator_type& __a)
842 : unordered_multimap(__n, __hf, key_equal(), __a)
845 template<
typename _InputIterator>
846 unordered_multimap(_InputIterator __first, _InputIterator __last,
848 const allocator_type& __a)
849 : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a)
852 template<
typename _InputIterator>
853 unordered_multimap(_InputIterator __first, _InputIterator __last,
854 size_type __n,
const hasher& __hf,
855 const allocator_type& __a)
856 : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
861 const allocator_type& __a)
862 : unordered_multimap(__l, __n, hasher(), key_equal(), __a)
866 size_type __n,
const hasher& __hf,
867 const allocator_type& __a)
868 : unordered_multimap(__l, __n, __hf, key_equal(), __a)
871 ~unordered_multimap() =
default;
874 operator=(
const unordered_multimap&) =
default;
877 operator=(unordered_multimap&&) =
default;
882 this->_M_base() = __l;
883 this->_M_invalidate_all();
888 swap(unordered_multimap& __x)
889 noexcept( noexcept(declval<_Base&>().swap(__x)) )
899 this->_M_invalidate_all();
907 begin() const noexcept
923 cend() const noexcept
930 __glibcxx_check_bucket_index(__b);
937 __glibcxx_check_bucket_index(__b);
942 begin(size_type __b)
const 944 __glibcxx_check_bucket_index(__b);
949 end(size_type __b)
const 951 __glibcxx_check_bucket_index(__b);
956 cbegin(size_type __b)
const 958 __glibcxx_check_bucket_index(__b);
963 cend(size_type __b)
const 965 __glibcxx_check_bucket_index(__b);
970 bucket_size(size_type __b)
const 972 __glibcxx_check_bucket_index(__b);
973 return _Base::bucket_size(__b);
977 max_load_factor() const noexcept
978 {
return _Base::max_load_factor(); }
981 max_load_factor(
float __f)
983 __glibcxx_check_max_load_factor(__f);
984 _Base::max_load_factor(__f);
987 template<
typename... _Args>
989 emplace(_Args&&... __args)
991 size_type __bucket_count = this->bucket_count();
992 auto __it = _Base::emplace(std::forward<_Args>(__args)...);
993 _M_check_rehashed(__bucket_count);
994 return { __it,
this };
997 template<
typename... _Args>
999 emplace_hint(const_iterator __hint, _Args&&... __args)
1002 size_type __bucket_count = this->bucket_count();
1003 auto __it = _Base::emplace_hint(__hint.
base(),
1004 std::forward<_Args>(__args)...);
1005 _M_check_rehashed(__bucket_count);
1006 return { __it,
this };
1010 insert(
const value_type& __obj)
1012 size_type __bucket_count = this->bucket_count();
1013 auto __it = _Base::insert(__obj);
1014 _M_check_rehashed(__bucket_count);
1015 return { __it,
this };
1021 insert(value_type&& __x)
1023 size_type __bucket_count = this->bucket_count();
1024 auto __it = _Base::insert(std::move(__x));
1025 _M_check_rehashed(__bucket_count);
1026 return { __it,
this };
1030 insert(const_iterator __hint,
const value_type& __obj)
1033 size_type __bucket_count = this->bucket_count();
1034 auto __it = _Base::insert(__hint.
base(), __obj);
1035 _M_check_rehashed(__bucket_count);
1036 return { __it,
this };
1042 insert(const_iterator __hint, value_type&& __x)
1045 size_type __bucket_count = this->bucket_count();
1046 auto __it = _Base::insert(__hint.
base(), std::move(__x));
1047 _M_check_rehashed(__bucket_count);
1048 return { __it,
this };
1051 template<
typename _Pair,
typename =
typename 1053 _Pair&&>::value>::type>
1055 insert(_Pair&& __obj)
1057 size_type __bucket_count = this->bucket_count();
1058 auto __it = _Base::insert(std::forward<_Pair>(__obj));
1059 _M_check_rehashed(__bucket_count);
1060 return { __it,
this };
1063 template<
typename _Pair,
typename =
typename 1065 _Pair&&>::value>::type>
1067 insert(const_iterator __hint, _Pair&& __obj)
1070 size_type __bucket_count = this->bucket_count();
1071 auto __it = _Base::insert(__hint.
base(), std::forward<_Pair>(__obj));
1072 _M_check_rehashed(__bucket_count);
1073 return { __it,
this };
1078 { _Base::insert(__l); }
1080 template<
typename _InputIterator>
1082 insert(_InputIterator __first, _InputIterator __last)
1085 __glibcxx_check_valid_range2(__first, __last, __dist);
1086 size_type __bucket_count = this->bucket_count();
1088 if (__dist.
second >= __gnu_debug::__dp_sign)
1089 _Base::insert(__gnu_debug::__unsafe(__first),
1090 __gnu_debug::__unsafe(__last));
1092 _Base::insert(__first, __last);
1094 _M_check_rehashed(__bucket_count);
1097 #if __cplusplus > 201402L 1098 using node_type =
typename _Base::node_type;
1101 extract(const_iterator __position)
1104 return _M_extract(__position.
base());
1108 extract(
const key_type& __key)
1110 const auto __position = _Base::find(__key);
1112 return _M_extract(__position);
1117 insert(node_type&& __nh)
1118 {
return { _Base::insert(std::move(__nh)),
this }; }
1121 insert(const_iterator __hint, node_type&& __nh)
1124 return { _Base::insert(__hint.
base(), std::move(__nh)),
this };
1131 find(
const key_type& __key)
1132 {
return { _Base::find(__key),
this }; }
1135 find(
const key_type& __key)
const 1136 {
return { _Base::find(__key),
this }; }
1139 equal_range(
const key_type& __key)
1141 auto __res = _Base::equal_range(__key);
1142 return { { __res.first,
this }, { __res.second,
this } };
1146 equal_range(
const key_type& __key)
const 1148 auto __res = _Base::equal_range(__key);
1149 return { { __res.first,
this }, { __res.second,
this } };
1153 erase(
const key_type& __key)
1156 size_type __bucket_count = this->bucket_count();
1157 auto __pair = _Base::equal_range(__key);
1158 for (
auto __victim = __pair.first; __victim != __pair.second;)
1160 _M_invalidate(__victim);
1161 __victim = _Base::erase(__victim);
1165 _M_check_rehashed(__bucket_count);
1170 erase(const_iterator __it)
1173 return { _M_erase(__it.
base()),
this };
1177 erase(iterator __it)
1180 return { _M_erase(__it.
base()),
this };
1184 erase(const_iterator __first, const_iterator __last)
1187 for (
auto __tmp = __first.
base(); __tmp != __last.
base(); ++__tmp)
1190 _M_message(__gnu_debug::__msg_valid_range)
1191 ._M_iterator(__first,
"first")
1192 ._M_iterator(__last,
"last"));
1193 _M_invalidate(__tmp);
1196 size_type __bucket_count = this->bucket_count();
1197 auto __next = _Base::erase(__first.
base(), __last.
base());
1198 _M_check_rehashed(__bucket_count);
1199 return { __next,
this };
1203 _M_base() noexcept {
return *
this; }
1206 _M_base() const noexcept {
return *
this; }
1210 _M_check_rehashed(size_type __prev_count)
1212 if (__prev_count != this->bucket_count())
1213 this->_M_invalidate_locals();
1217 _M_invalidate(_Base_const_iterator __victim)
1219 this->_M_invalidate_if(
1220 [__victim](_Base_const_iterator __it) {
return __it == __victim; });
1221 this->_M_invalidate_local_if(
1222 [__victim](_Base_const_local_iterator __it)
1223 {
return __it._M_curr() == __victim._M_cur; });
1227 _M_erase(_Base_const_iterator __victim)
1229 _M_invalidate(__victim);
1230 size_type __bucket_count = this->bucket_count();
1231 _Base_iterator __next = _Base::erase(__victim);
1232 _M_check_rehashed(__bucket_count);
1236 #if __cplusplus > 201402L 1238 _M_extract(_Base_const_iterator __victim)
1240 _M_invalidate(__victim);
1241 return _Base::extract(__victim);
1246 #if __cpp_deduction_guides >= 201606 1248 template<
typename _InputIterator,
1249 typename _Hash = hash<__iter_key_t<_InputIterator>>,
1250 typename _Pred = equal_to<__iter_key_t<_InputIterator>>,
1252 typename = _RequireInputIter<_InputIterator>,
1253 typename = _RequireAllocator<_Allocator>>
1254 unordered_multimap(_InputIterator, _InputIterator,
1255 unordered_multimap<int, int>::size_type = {},
1256 _Hash = _Hash(), _Pred = _Pred(),
1257 _Allocator = _Allocator())
1258 -> unordered_multimap<__iter_key_t<_InputIterator>,
1259 __iter_val_t<_InputIterator>, _Hash, _Pred,
1262 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1263 typename _Pred = equal_to<_Key>,
1264 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1265 typename = _RequireAllocator<_Allocator>>
1267 unordered_multimap<int, int>::size_type = {},
1268 _Hash = _Hash(), _Pred = _Pred(),
1269 _Allocator = _Allocator())
1272 template<
typename _InputIterator,
typename _Allocator,
1273 typename = _RequireInputIter<_InputIterator>,
1274 typename = _RequireAllocator<_Allocator>>
1275 unordered_multimap(_InputIterator, _InputIterator,
1276 unordered_multimap<int, int>::size_type, _Allocator)
1278 __iter_val_t<_InputIterator>,
1279 hash<__iter_key_t<_InputIterator>>,
1280 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1282 template<
typename _InputIterator,
typename _Allocator,
1283 typename = _RequireInputIter<_InputIterator>,
1284 typename = _RequireAllocator<_Allocator>>
1285 unordered_multimap(_InputIterator, _InputIterator, _Allocator)
1287 __iter_val_t<_InputIterator>,
1288 hash<__iter_key_t<_InputIterator>>,
1289 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1291 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1292 typename = _RequireInputIter<_InputIterator>,
1293 typename = _RequireAllocator<_Allocator>>
1294 unordered_multimap(_InputIterator, _InputIterator,
1295 unordered_multimap<int, int>::size_type, _Hash,
1298 __iter_val_t<_InputIterator>, _Hash,
1299 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1301 template<
typename _Key,
typename _Tp,
typename _Allocator,
1302 typename = _RequireAllocator<_Allocator>>
1304 unordered_multimap<int, int>::size_type,
1308 template<
typename _Key,
typename _Tp,
typename _Allocator,
1309 typename = _RequireAllocator<_Allocator>>
1313 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1314 typename = _RequireAllocator<_Allocator>>
1316 unordered_multimap<int, int>::size_type,
1322 template<
typename _Key,
typename _Tp,
typename _Hash,
1323 typename _Pred,
typename _Alloc>
1327 noexcept(noexcept(__x.swap(__y)))
1330 template<
typename _Key,
typename _Tp,
typename _Hash,
1331 typename _Pred,
typename _Alloc>
1335 {
return __x._M_base() == __y._M_base(); }
1337 template<
typename _Key,
typename _Tp,
typename _Hash,
1338 typename _Pred,
typename _Alloc>
1342 {
return !(__x == __y); }
Base class that supports tracking of iterators that reference a sequence.
Base class for constructing a safe unordered container type that tracks iterators that reference it...
Class std::unordered_multimap with safety/checking/debug instrumentation.
Define a member typedef type only if a boolean constant is true.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
#define __glibcxx_check_erase_range(_First, _Last)
Class std::unordered_map with safety/checking/debug instrumentation.
Primary class template hash.
constexpr auto cend(const _Container &__cont) noexcept(noexcept(std::end(__cont))) -> decltype(std::end(__cont))
Return an iterator pointing to one past the last element of the const container.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
ISO C++ entities toplevel namespace is std.
The standard allocator, as per [20.4].
One of the comparison functors.
Struct holding two objects of arbitrary type.
_T2 second
first is a copy of the first object
#define __glibcxx_check_insert(_Position)
_Iterator __base(_Iterator __it)
_Iterator & base() noexcept
Return the underlying iterator.
GNU debug classes for public use.
Safe class dealing with some allocator dependent operations.
#define __glibcxx_check_erase(_Position)
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
Return an iterator pointing to the first element of the const container.