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;
65 typedef _Tp mapped_type;
67 typedef _Compare key_compare;
69 typedef typename _Base::reference reference;
70 typedef typename _Base::const_reference const_reference;
77 typedef typename _Base::size_type size_type;
78 typedef typename _Base::difference_type difference_type;
79 typedef typename _Base::pointer pointer;
80 typedef typename _Base::const_pointer const_pointer;
86#if __cplusplus < 201103L
99 const _Compare& __c = _Compare(),
118 template<
typename _InputIterator>
122 __glibcxx_check_valid_constructor_range(__first, __last)),
132 explicit map(
const _Compare& __comp,
134 :
_Base(__comp, __a) { }
136 template<
typename _InputIterator>
138 const _Compare& __comp = _Compare(),
141 __glibcxx_check_valid_constructor_range(__first, __last)),
145#if __cplusplus < 201103L
147 operator=(
const map& __x)
149 this->_M_safe() = __x;
155 operator=(
const map&) =
default;
158 operator=(
map&&) =
default;
164 this->_M_invalidate_all();
171 using _Base::get_allocator;
176 {
return iterator(_Base::begin(),
this); }
184 {
return iterator(_Base::end(),
this); }
206#if __cplusplus >= 201103L
208 cbegin()
const noexcept
212 cend()
const noexcept
216 crbegin()
const noexcept
220 crend()
const noexcept
227 using _Base::max_size;
230 using _Base::operator[];
237#if __cplusplus >= 201103L
238 template<
typename...
_Args>
243 return { {
__res.first,
this },
__res.second };
246 template<
typename...
_Args>
267#if __cplusplus >= 201103L
274 return { {
__res.first,
this },
__res.second };
277 template<
typename _Pair,
typename =
typename
279 _Pair&&>::value>::type>
284 return { {
__res.first,
this },
__res.second };
288#if __cplusplus >= 201103L
291 { _Base::insert(
__list); }
295#if __cplusplus >= 201103L
305#if __cplusplus >= 201103L
315 template<
typename _Pair,
typename =
typename
317 _Pair&&>::value>::type>
330 template<
typename _InputIterator>
335 __glibcxx_check_valid_range2(__first, __last,
__dist);
337 if (
__dist.second >= __gnu_debug::__dp_sign)
338 _Base::insert(__gnu_debug::__unsafe(__first),
339 __gnu_debug::__unsafe(__last));
341 _Base::insert(__first, __last);
345#if __cplusplus > 201402L
346 template <
typename...
_Args>
350 auto __res = _Base::try_emplace(
__k,
352 return { {
__res.first,
this },
__res.second };
355 template <
typename...
_Args>
361 return { {
__res.first,
this },
__res.second };
364 template <
typename...
_Args>
378 template <
typename...
_Args>
391 template <
typename _Obj>
395 auto __res = _Base::insert_or_assign(
__k,
397 return { {
__res.first,
this },
__res.second };
400 template <
typename _Obj>
406 return { {
__res.first,
this },
__res.second };
409 template <
typename _Obj>
417 _Base::insert_or_assign(
__hint.base(),
__k,
423 template <
typename _Obj>
437#if __cplusplus > 201402L
438 using node_type =
typename _Base::node_type;
459 insert(node_type&&
__nh)
476#if __cplusplus >= 201103L
482 return { _Base::erase(
__position.base()),
this };
485 _GLIBCXX_ABI_TAG_CXX11
513#if __cplusplus >= 201103L
523 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::cend(),
524 _M_message(__gnu_debug::__msg_valid_range)
525 ._M_iterator(__first,
"first")
526 ._M_iterator(__last,
"last"));
530 return { _Base::erase(__first.base(), __last.
base()),
this };
542 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::end(),
543 _M_message(__gnu_debug::__msg_valid_range)
544 ._M_iterator(__first,
"first")
545 ._M_iterator(__last,
"last"));
548 _Base::erase(__first.base(), __last.
base());
563 this->_M_invalidate_all();
568 using _Base::key_comp;
569 using _Base::value_comp;
574 {
return iterator(_Base::find(__x),
this); }
576#if __cplusplus > 201103L
577 template<
typename _Kt,
579 typename __has_is_transparent<_Compare, _Kt>::type>
582 {
return { _Base::find(__x),
this }; }
589#if __cplusplus > 201103L
590 template<
typename _Kt,
592 typename __has_is_transparent<_Compare, _Kt>::type>
594 find(
const _Kt& __x)
const
595 {
return { _Base::find(__x),
this }; }
602 {
return iterator(_Base::lower_bound(__x),
this); }
604#if __cplusplus > 201103L
605 template<
typename _Kt,
607 typename __has_is_transparent<_Compare, _Kt>::type>
609 lower_bound(
const _Kt& __x)
610 {
return { _Base::lower_bound(__x),
this }; }
614 lower_bound(
const key_type& __x)
const
617#if __cplusplus > 201103L
618 template<
typename _Kt,
620 typename __has_is_transparent<_Compare, _Kt>::type>
622 lower_bound(
const _Kt& __x)
const
623 {
return { _Base::lower_bound(__x),
this }; }
628 {
return iterator(_Base::upper_bound(__x),
this); }
630#if __cplusplus > 201103L
631 template<
typename _Kt,
633 typename __has_is_transparent<_Compare, _Kt>::type>
635 upper_bound(
const _Kt& __x)
636 {
return { _Base::upper_bound(__x),
this }; }
640 upper_bound(
const key_type& __x)
const
643#if __cplusplus > 201103L
644 template<
typename _Kt,
646 typename __has_is_transparent<_Compare, _Kt>::type>
648 upper_bound(
const _Kt& __x)
const
649 {
return { _Base::upper_bound(__x),
this }; }
656 _Base::equal_range(__x);
661#if __cplusplus > 201103L
662 template<
typename _Kt,
664 typename __has_is_transparent<_Compare, _Kt>::type>
666 equal_range(
const _Kt& __x)
668 auto __res = _Base::equal_range(__x);
669 return { {
__res.first,
this }, {
__res.second,
this } };
674 equal_range(
const key_type& __x)
const
677 _Base::equal_range(__x);
682#if __cplusplus > 201103L
683 template<
typename _Kt,
685 typename __has_is_transparent<_Compare, _Kt>::type>
687 equal_range(
const _Kt& __x)
const
689 auto __res = _Base::equal_range(__x);
690 return { {
__res.first,
this }, {
__res.second,
this } };
701#if __cpp_deduction_guides >= 201606
714 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
715 typename _Allocator = allocator<pair<const _Key, _Tp>>,
716 typename = _RequireNotAllocator<_Compare>,
717 typename = _RequireAllocator<_Allocator>>
736 template<
typename _Key,
typename _Tp,
741 {
return __lhs._M_base() ==
__rhs._M_base(); }
743#if __cpp_lib_three_way_comparison
744 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
745 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
748 {
return __lhs._M_base() <=>
__rhs._M_base(); }
750 template<
typename _Key,
typename _Tp,
751 typename _Compare,
typename _Allocator>
753 operator!=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
754 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
755 {
return __lhs._M_base() != __rhs._M_base(); }
757 template<
typename _Key,
typename _Tp,
758 typename _Compare,
typename _Allocator>
760 operator<(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
761 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
762 {
return __lhs._M_base() < __rhs._M_base(); }
764 template<
typename _Key,
typename _Tp,
765 typename _Compare,
typename _Allocator>
767 operator<=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
768 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
769 {
return __lhs._M_base() <= __rhs._M_base(); }
771 template<
typename _Key,
typename _Tp,
772 typename _Compare,
typename _Allocator>
774 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
775 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
776 {
return __lhs._M_base() >= __rhs._M_base(); }
778 template<
typename _Key,
typename _Tp,
779 typename _Compare,
typename _Allocator>
781 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
782 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
783 {
return __lhs._M_base() > __rhs._M_base(); }
786 template<
typename _Key,
typename _Tp,
787 typename _Compare,
typename _Allocator>
789 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
790 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
791 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
792 { __lhs.swap(__rhs); }
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
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.
Struct holding two objects of arbitrary type.
_Iterator & base() noexcept
Return the underlying iterator.
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...