29#ifndef _GLIBCXX_DEBUG_MAP_H
30#define _GLIBCXX_DEBUG_MAP_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> > >
46 map<_Key, _Tp, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
50 typedef _GLIBCXX_STD_C::map<
59 template<
typename _ItT,
typename _SeqT,
typename _CatT>
60 friend class ::__gnu_debug::_Safe_iterator;
67 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
75 typedef _Tp mapped_type;
77 typedef _Compare key_compare;
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
105 map(
const map&) =
default;
109 const _Compare& __c = _Compare(),
128 template<
typename _InputIterator>
132 __glibcxx_check_valid_constructor_range(__first, __last)),
136#if __glibcxx_containers_ranges
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
148 template<std::__detail::__container_compatible_range<value_type> _Rg>
159 :
_Base(__x._M_ref) { }
161 explicit map(
const _Compare& __comp,
163 :
_Base(__comp, __a) { }
165 template<
typename _InputIterator>
167 const _Compare& __comp = _Compare(),
170 __glibcxx_check_valid_constructor_range(__first, __last)),
174#if __cplusplus >= 201103L
176 operator=(
const map&) =
default;
179 operator=(
map&&) =
default;
184 _Base::operator=(
__l);
185 this->_M_invalidate_all();
192 using _Base::get_allocator;
197 {
return iterator(_Base::begin(),
this); }
205 {
return iterator(_Base::end(),
this); }
227#if __cplusplus >= 201103L
229 cbegin()
const noexcept
233 cend()
const noexcept
237 crbegin()
const noexcept
241 crend()
const noexcept
248 using _Base::max_size;
251 using _Base::operator[];
258#if __cplusplus >= 201103L
259 template<
typename...
_Args>
264 return { {
__res.first,
this },
__res.second };
267 template<
typename...
_Args>
288#if __cplusplus >= 201103L
295 return { {
__res.first,
this },
__res.second };
298 template<
typename _Pair,
typename =
typename
300 _Pair&&>::value>::type>
305 return { {
__res.first,
this },
__res.second };
309#if __cplusplus >= 201103L
312 { _Base::insert(__list); }
316#if __cplusplus >= 201103L
326#if __cplusplus >= 201103L
336 template<
typename _Pair,
typename =
typename
338 _Pair&&>::value>::type>
351 template<
typename _InputIterator>
356 __glibcxx_check_valid_range2(__first, __last,
__dist);
358 if (
__dist.second >= __gnu_debug::__dp_sign)
359 _Base::insert(__gnu_debug::__unsafe(__first),
360 __gnu_debug::__unsafe(__last));
362 _Base::insert(__first, __last);
366#ifdef __glibcxx_map_try_emplace
367 template <
typename...
_Args>
371 auto __res = _Base::try_emplace(
__k,
373 return { {
__res.first,
this },
__res.second };
376 template <
typename...
_Args>
382 return { {
__res.first,
this },
__res.second };
385 template <
typename...
_Args>
399 template <
typename...
_Args>
412 template <
typename _Obj>
416 auto __res = _Base::insert_or_assign(
__k,
418 return { {
__res.first,
this },
__res.second };
421 template <
typename _Obj>
427 return { {
__res.first,
this },
__res.second };
430 template <
typename _Obj>
438 _Base::insert_or_assign(
__hint.base(),
__k,
444 template <
typename _Obj>
458#if __cplusplus > 201402L
459 using node_type =
typename _Base::node_type;
480 insert(node_type&&
__nh)
497#if __cplusplus >= 201103L
513 _GLIBCXX_ABI_TAG_CXX11
541#if __cplusplus >= 201103L
551 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::cend(),
552 _M_message(__gnu_debug::__msg_valid_range)
553 ._M_iterator(__first,
"first")
554 ._M_iterator(__last,
"last"));
558 return { _Base::erase(__first.base(), __last.
base()),
this };
570 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::end(),
571 _M_message(__gnu_debug::__msg_valid_range)
572 ._M_iterator(__first,
"first")
573 ._M_iterator(__last,
"last"));
576 _Base::erase(__first.base(), __last.
base());
591 this->_M_invalidate_all();
596 using _Base::key_comp;
597 using _Base::value_comp;
602 {
return iterator(_Base::find(__x),
this); }
604#if __cplusplus > 201103L
605 template<
typename _Kt,
607 typename __has_is_transparent<_Compare, _Kt>::type>
610 {
return { _Base::find(__x),
this }; }
617#if __cplusplus > 201103L
618 template<
typename _Kt,
620 typename __has_is_transparent<_Compare, _Kt>::type>
622 find(
const _Kt& __x)
const
623 {
return { _Base::find(__x),
this }; }
630 {
return iterator(_Base::lower_bound(__x),
this); }
632#if __cplusplus > 201103L
633 template<
typename _Kt,
635 typename __has_is_transparent<_Compare, _Kt>::type>
637 lower_bound(
const _Kt& __x)
638 {
return { _Base::lower_bound(__x),
this }; }
642 lower_bound(
const key_type& __x)
const
645#if __cplusplus > 201103L
646 template<
typename _Kt,
648 typename __has_is_transparent<_Compare, _Kt>::type>
650 lower_bound(
const _Kt& __x)
const
651 {
return { _Base::lower_bound(__x),
this }; }
656 {
return iterator(_Base::upper_bound(__x),
this); }
658#if __cplusplus > 201103L
659 template<
typename _Kt,
661 typename __has_is_transparent<_Compare, _Kt>::type>
663 upper_bound(
const _Kt& __x)
664 {
return { _Base::upper_bound(__x),
this }; }
668 upper_bound(
const key_type& __x)
const
671#if __cplusplus > 201103L
672 template<
typename _Kt,
674 typename __has_is_transparent<_Compare, _Kt>::type>
676 upper_bound(
const _Kt& __x)
const
677 {
return { _Base::upper_bound(__x),
this }; }
684 _Base::equal_range(__x);
689#if __cplusplus > 201103L
690 template<
typename _Kt,
692 typename __has_is_transparent<_Compare, _Kt>::type>
694 equal_range(
const _Kt& __x)
696 auto __res = _Base::equal_range(__x);
697 return { {
__res.first,
this }, {
__res.second,
this } };
702 equal_range(
const key_type& __x)
const
705 _Base::equal_range(__x);
710#if __cplusplus > 201103L
711 template<
typename _Kt,
713 typename __has_is_transparent<_Compare, _Kt>::type>
715 equal_range(
const _Kt& __x)
const
717 auto __res = _Base::equal_range(__x);
718 return { {
__res.first,
this }, {
__res.second,
this } };
729#if __cpp_deduction_guides >= 201606
742 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
743 typename _Allocator = allocator<pair<const _Key, _Tp>>,
744 typename = _RequireNotAllocator<_Compare>,
745 typename = _RequireAllocator<_Allocator>>
762#if __glibcxx_containers_ranges
763 template<ranges::input_range
_Rg,
769 __detail::__range_mapped_type<_Rg>,
772 template<ranges::input_range _Rg, __allocator_like _Alloc>
775 __detail::__range_mapped_type<_Rg>,
781 template<
typename _Key,
typename _Tp,
786 {
return __lhs._M_base() ==
__rhs._M_base(); }
788#if __cpp_lib_three_way_comparison
789 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
790 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
793 {
return __lhs._M_base() <=>
__rhs._M_base(); }
795 template<
typename _Key,
typename _Tp,
796 typename _Compare,
typename _Allocator>
798 operator!=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
799 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
800 {
return __lhs._M_base() != __rhs._M_base(); }
802 template<
typename _Key,
typename _Tp,
803 typename _Compare,
typename _Allocator>
805 operator<(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
806 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
807 {
return __lhs._M_base() < __rhs._M_base(); }
809 template<
typename _Key,
typename _Tp,
810 typename _Compare,
typename _Allocator>
812 operator<=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
813 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
814 {
return __lhs._M_base() <= __rhs._M_base(); }
816 template<
typename _Key,
typename _Tp,
817 typename _Compare,
typename _Allocator>
819 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
820 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
821 {
return __lhs._M_base() >= __rhs._M_base(); }
823 template<
typename _Key,
typename _Tp,
824 typename _Compare,
typename _Allocator>
826 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
827 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
828 {
return __lhs._M_base() > __rhs._M_base(); }
831 template<
typename _Key,
typename _Tp,
832 typename _Compare,
typename _Allocator>
834 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
835 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
836 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
837 { __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.
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
Define a member typedef type only if a boolean constant is true.
constexpr _Iterator & base() noexcept
Return the underlying iterator.
Struct holding two objects of arbitrary type.
Class std::map 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...