29#ifndef _GLIBCXX_DEBUG_MAP_H
30#define _GLIBCXX_DEBUG_MAP_H 1
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;
96#if __cplusplus < 201103L
111 :
_Base(__l, __c, __a) { }
117 map(
const map& __m,
const __type_identity_t<allocator_type>& __a)
118 :
_Base(__m, __a) { }
120 map(
map&& __m,
const __type_identity_t<allocator_type>& __a)
126 :
_Base(__l, __a) { }
128 template<
typename _InputIterator>
129 map(_InputIterator __first, _InputIterator __last,
136#if __glibcxx_containers_ranges
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
142 map(std::from_range_t __t, _Rg&& __rg,
145 : _Base(__t,
std::
forward<_Rg>(__rg), __c, __a)
148 template<std::__detail::__container_compatible_range<value_type> _Rg>
149 map(std::from_range_t __t, _Rg&& __rg,
159 :
_Base(__x._M_ref) { }
162 const _Allocator& __a = _Allocator())
163 :
_Base(__comp, __a) { }
165 template<
typename _InputIterator>
166 map(_InputIterator __first, _InputIterator __last,
168 const _Allocator& __a = _Allocator())
174#if __cplusplus >= 201103L
185 this->_M_invalidate_all();
192 using _Base::get_allocator;
208 end() const _GLIBCXX_NOEXCEPT
227#if __cplusplus >= 201103L
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
305 return { { __res.first,
this }, __res.second };
309#if __cplusplus >= 201103L
316#if __cplusplus >= 201103L
326#if __cplusplus >= 201103L
336 template<
typename _Pair,
typename =
typename
351 template<
typename _InputIterator>
353 insert(_InputIterator __first, _InputIterator __last)
366#ifdef __glibcxx_map_try_emplace
367 template <
typename... _Args>
369 try_emplace(
const key_type& __k, _Args&&... __args)
371 auto __res = _Base::try_emplace(__k,
373 return { { __res.first,
this }, __res.second };
376 template <
typename... _Args>
378 try_emplace(
key_type&& __k, _Args&&... __args)
380 auto __res = _Base::try_emplace(
std::move(__k),
382 return { { __res.first,
this }, __res.second };
385# ifdef __glibcxx_associative_heterogeneous_insertion
386 template <__heterogeneous_tree_key<map> _Kt,
typename... _Args>
388 try_emplace(_Kt&& __k, _Args&&... __args)
390 auto __res = _Base::try_emplace(
392 return { { __res.first,
this }, __res.second };
396 template <
typename... _Args>
402 auto __it = _Base::try_emplace(__hint.base(), __k,
404 return { __it,
this };
407 template <
typename... _Args>
412 auto __it = _Base::try_emplace(__hint.base(),
std::move(__k),
414 return { __it,
this };
417# ifdef __glibcxx_associative_heterogeneous_insertion
418 template <__heterogeneous_tree_key<map> _Kt,
typename... _Args>
423 auto __it = _Base::try_emplace(__hint.base(),
425 return { __it,
this };
429 template <
typename _Obj>
431 insert_or_assign(
const key_type& __k, _Obj&& __obj)
433 auto __res = _Base::insert_or_assign(__k,
435 return { { __res.first,
this }, __res.second };
438 template <
typename _Obj>
440 insert_or_assign(
key_type&& __k, _Obj&& __obj)
442 auto __res = _Base::insert_or_assign(
std::move(__k),
444 return { { __res.first,
this }, __res.second };
447# ifdef __glibcxx_associative_heterogeneous_insertion
448 template <__heterogeneous_tree_key<map> _Kt,
typename _Obj>
450 insert_or_assign(_Kt&& __k, _Obj&& __obj)
452 auto __res = _Base::insert_or_assign(
454 return { { __res.first,
this }, __res.second };
458 template <
typename _Obj>
464 auto __it = _Base::insert_or_assign(__hint.base(), __k,
466 return { __it,
this };
469 template <
typename _Obj>
474 auto __it = _Base::insert_or_assign(__hint.base(),
std::move(__k),
476 return { __it,
this };
479# ifdef __glibcxx_associative_heterogeneous_insertion
480 template <__heterogeneous_tree_key<map> _Kt,
typename _Obj>
485 auto __it = _Base::insert_or_assign(__hint.base(),
487 return { __it,
this };
493#ifdef __glibcxx_node_extract
494 using node_type =
typename _Base::node_type;
495 using insert_return_type = _Node_insert_return<iterator, node_type>;
501 this->_M_invalidate_if(
_Equal(__position.base()));
502 return _Base::extract(__position.base());
508 const auto __position =
find(__key);
509 if (__position !=
end())
510 return extract(__position);
514# ifdef __glibcxx_associative_heterogeneous_erasure
515 template <__heterogeneous_tree_key<map> _Kt>
519 const auto __position =
find(__key);
520 if (__position !=
end())
521 return extract(__position);
531 { { __ret.position,
this }, __ret.inserted,
std::move(__ret.node) };
544#if __cplusplus >= 201103L
549 return {
erase(__position.
base()),
this };
556 this->_M_invalidate_if(
_Equal(__position));
569 this->_M_invalidate_if(
_Equal(__position.base()));
582 this->_M_invalidate_if(
_Equal(__victim));
588# ifdef __glibcxx_associative_heterogeneous_erasure
592 template <__heterogeneous_tree_key<map> _Kt>
598 for (
auto __victim = __victims.first; __victim != __victims.second;)
600 this->_M_invalidate_if(
_Equal(__victim));
608#if __cplusplus >= 201103L
616 __victim != __last.
base(); ++__victim)
620 ._M_iterator(__first,
"first")
621 ._M_iterator(__last,
"last"));
622 this->_M_invalidate_if(
_Equal(__victim));
634 for (_Base_iterator __victim = __first.base();
635 __victim != __last.base(); ++__victim)
639 ._M_iterator(__first,
"first")
640 ._M_iterator(__last,
"last"));
641 this->_M_invalidate_if(
_Equal(__victim));
658 this->_M_invalidate_all();
663 using _Base::key_comp;
664 using _Base::value_comp;
671#ifdef __glibcxx_generic_associative_lookup
672 template<
typename _Kt,
684#ifdef __glibcxx_generic_associative_lookup
685 template<
typename _Kt,
689 find(
const _Kt& __x)
const
699#ifdef __glibcxx_generic_associative_lookup
700 template<
typename _Kt,
712#ifdef __glibcxx_generic_associative_lookup
713 template<
typename _Kt,
725#ifdef __glibcxx_generic_associative_lookup
726 template<
typename _Kt,
738#ifdef __glibcxx_generic_associative_lookup
739 template<
typename _Kt,
756#ifdef __glibcxx_generic_associative_lookup
757 template<
typename _Kt,
764 return { { __res.first,
this }, { __res.second,
this } };
777#ifdef __glibcxx_generic_associative_lookup
778 template<
typename _Kt,
785 return { { __res.first,
this }, { __res.second,
this } };
793 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
796#if __cpp_deduction_guides >= 201606
798 template<
typename _InputIterator,
802 typename = _RequireNotAllocator<_Compare>,
803 typename = _RequireAllocator<_Allocator>>
804 map(_InputIterator, _InputIterator,
809 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
810 typename _Allocator = allocator<pair<const _Key, _Tp>>,
811 typename = _RequireNotAllocator<_Compare>,
812 typename = _RequireAllocator<_Allocator>>
817 template <
typename _InputIterator,
typename _Allocator,
819 typename = _RequireAllocator<_Allocator>>
820 map(_InputIterator, _InputIterator, _Allocator)
824 template<
typename _Key,
typename _Tp,
typename _Allocator,
825 typename = _RequireAllocator<_Allocator>>
829#if __glibcxx_containers_ranges
832 __allocator_like _Alloc =
836 __detail::__range_mapped_type<_Rg>,
839 template<ranges::input_range _Rg, __allocator_like _Alloc>
840 map(from_range_t, _Rg&&, _Alloc)
842 __detail::__range_mapped_type<_Rg>,
848 template<
typename _Key,
typename _Tp,
849 typename _Compare,
typename _Allocator>
855#if __cpp_lib_three_way_comparison
856 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
857 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
860 {
return __lhs._M_base() <=> __rhs._M_base(); }
862 template<
typename _Key,
typename _Tp,
863 typename _Compare,
typename _Allocator>
867 {
return __lhs._M_base() != __rhs._M_base(); }
869 template<
typename _Key,
typename _Tp,
870 typename _Compare,
typename _Allocator>
874 {
return __lhs._M_base() < __rhs._M_base(); }
876 template<
typename _Key,
typename _Tp,
877 typename _Compare,
typename _Allocator>
881 {
return __lhs._M_base() <= __rhs._M_base(); }
883 template<
typename _Key,
typename _Tp,
884 typename _Compare,
typename _Allocator>
888 {
return __lhs._M_base() >= __rhs._M_base(); }
890 template<
typename _Key,
typename _Tp,
891 typename _Compare,
typename _Allocator>
895 {
return __lhs._M_base() > __rhs._M_base(); }
898 template<
typename _Key,
typename _Tp,
899 typename _Compare,
typename _Allocator>
903 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
904 { __lhs.swap(__rhs); }
#define _GLIBCXX_VISIBILITY(V)
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_valid_range2(_First, _Last, _Dist)
#define __glibcxx_check_erase2(_CPosition)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
#define _GLIBCXX_DEBUG_VERIFY(_Cond, _ErrMsg)
#define __glibcxx_check_valid_constructor_range(_First, _Last)
#define _GLIBCXX_ABI_TAG_CXX11
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.
constexpr bool operator>(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
constexpr bool operator<(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
constexpr bool operator<=(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
constexpr bool operator>=(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
__remove_cvref_t< typename iterator_traits< _InputIterator >::value_type::second_type > __iter_val_t
bool operator!=(const fpos< _StateT > &__lhs, const fpos< _StateT > &__rhs)
__enable_if_t< is_convertible< __iter_category_t< _InIter >, input_iterator_tag >::value > _RequireInputIter
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __unsafe(_Iterator __it)
GNU debug classes for public use.
void swap(map< _Key, _Tp, _Compare, _Allocator > &__lhs, map< _Key, _Tp, _Compare, _Allocator > &__rhs) noexcept(/*conditional */)
__detail::__synth3way_t< pair< const _Key, _Tp > > operator<=>(const map< _Key, _Tp, _Compare, _Alloc > &__lhs, const map< _Key, _Tp, _Compare, _Alloc > &__rhs)
map(_InputIterator, _InputIterator, _Compare=_Compare(), _Allocator=_Allocator()) -> map< __iter_key_t< _InputIterator >, __iter_val_t< _InputIterator >, _Compare, _Allocator >
bool operator==(const map< _Key, _Tp, _Compare, _Allocator > &__lhs, const map< _Key, _Tp, _Compare, _Allocator > &__rhs)
GNU debug code, replaces standard behavior with debug behavior.
Define a member typedef type only if a boolean constant is true.
The standard allocator, as per C++03 [20.4.1].
constexpr _Iterator & base() noexcept
Return the underlying iterator.
One of the comparison functors.
_T1 first
The first member.
_T2 second
The second member.
Struct holding two objects of arbitrary type.
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
void insert(std::initializer_list< value_type > __list)
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
void insert(_InputIterator __first, _InputIterator __last)
map(const allocator_type &__a)
map(map &&__m, const __type_identity_t< allocator_type > &__a) noexcept(noexcept(_Base(std::move(__m), __a)))
map & operator=(const map &)=default
const_iterator upper_bound(const key_type &__x) const
std::reverse_iterator< iterator > reverse_iterator
map(initializer_list< value_type > __l, const allocator_type &__a)
std::pair< iterator, bool > insert(value_type &&__x)
iterator upper_bound(const key_type &__x)
_Base::reference reference
_Base::size_type size_type
const_reverse_iterator rbegin() const noexcept
_Base_iterator erase(_Base_const_iterator __position)
iterator insert(const_iterator __position, _Pair &&__x)
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
_Base::const_reference const_reference
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
const _Base & _M_base() const noexcept
std::pair< iterator, bool > insert(const value_type &__x)
std::pair< const _Key, _Tp > value_type
iterator begin() noexcept
iterator find(const key_type &__x)
const_iterator end() const noexcept
iterator insert(const_iterator __position, value_type &&__x)
const_iterator lower_bound(const key_type &__x) const
_Allocator allocator_type
const_iterator find(const key_type &__x) const
std::reverse_iterator< const_iterator > const_reverse_iterator
__gnu_debug::_Safe_container< map, _Allocator, __gnu_debug::_Safe_node_sequence > _Safe
reverse_iterator rbegin() noexcept
const_iterator cend() const noexcept
__gnu_debug::_Equal_to< _Base_const_iterator > _Equal
const_iterator begin() const noexcept
map & operator=(initializer_list< value_type > __l)
__gnu_debug::_Safe_iterator< _Base_const_iterator, map > const_iterator
map(const map &__m, const __type_identity_t< allocator_type > &__a)
_Base::iterator _Base_iterator
void swap(map &__x) noexcept(/*conditional */)
_Base::const_iterator _Base_const_iterator
__gnu_debug::_Safe_iterator< _Base_iterator, map > iterator
const_reverse_iterator crbegin() const noexcept
const_reverse_iterator rend() const noexcept
std::pair< iterator, bool > emplace(_Args &&... __args)
_Base & _M_base() noexcept
iterator lower_bound(const key_type &__x)
std::pair< iterator, bool > insert(_Pair &&__x)
const_iterator cbegin() const noexcept
std::pair< iterator, iterator > equal_range(const key_type &__x)
map(initializer_list< value_type > __l, const _Compare &__c=_Compare(), const allocator_type &__a=allocator_type())
::map< _Key, _Tp, _Compare, _Allocator > _Base
map & operator=(map &&)=default
iterator erase(const_iterator __position)
map(const _Compare &__comp, const _Allocator &__a=_Allocator())
_Base::difference_type difference_type
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp=_Compare(), const _Allocator &__a=_Allocator())
reverse_iterator rend() noexcept
const_reverse_iterator crend() const noexcept
_Base::const_pointer const_pointer
size_type erase(const key_type &__x)
iterator insert(const_iterator __position, const value_type &__x)
iterator erase(const_iterator __first, const_iterator __last)
Class std::map with safety/checking/debug instrumentation.
_Base_ref(const _Base &__r)
constexpr void _M_swap(const _Safe_container &__x) const noexcept
Safe class dealing with some allocator dependent operations.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
A range for which ranges::begin returns an input iterator.