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)),
140 :
_Base(__x._M_ref) { }
142 explicit map(
const _Compare& __comp,
144 :
_Base(__comp, __a) { }
146 template<
typename _InputIterator>
148 const _Compare& __comp = _Compare(),
151 __glibcxx_check_valid_constructor_range(__first, __last)),
155#if __cplusplus >= 201103L
157 operator=(
const map&) =
default;
160 operator=(
map&&) =
default;
165 _Base::operator=(
__l);
166 this->_M_invalidate_all();
173 using _Base::get_allocator;
178 {
return iterator(_Base::begin(),
this); }
186 {
return iterator(_Base::end(),
this); }
208#if __cplusplus >= 201103L
210 cbegin()
const noexcept
214 cend()
const noexcept
218 crbegin()
const noexcept
222 crend()
const noexcept
229 using _Base::max_size;
232 using _Base::operator[];
239#if __cplusplus >= 201103L
240 template<
typename...
_Args>
245 return { {
__res.first,
this },
__res.second };
248 template<
typename...
_Args>
269#if __cplusplus >= 201103L
276 return { {
__res.first,
this },
__res.second };
279 template<
typename _Pair,
typename =
typename
281 _Pair&&>::value>::type>
286 return { {
__res.first,
this },
__res.second };
290#if __cplusplus >= 201103L
293 { _Base::insert(
__list); }
297#if __cplusplus >= 201103L
307#if __cplusplus >= 201103L
317 template<
typename _Pair,
typename =
typename
319 _Pair&&>::value>::type>
332 template<
typename _InputIterator>
337 __glibcxx_check_valid_range2(__first, __last,
__dist);
339 if (
__dist.second >= __gnu_debug::__dp_sign)
340 _Base::insert(__gnu_debug::__unsafe(__first),
341 __gnu_debug::__unsafe(__last));
343 _Base::insert(__first, __last);
347#ifdef __glibcxx_map_try_emplace
348 template <
typename...
_Args>
352 auto __res = _Base::try_emplace(
__k,
354 return { {
__res.first,
this },
__res.second };
357 template <
typename...
_Args>
363 return { {
__res.first,
this },
__res.second };
366 template <
typename...
_Args>
380 template <
typename...
_Args>
393 template <
typename _Obj>
397 auto __res = _Base::insert_or_assign(
__k,
399 return { {
__res.first,
this },
__res.second };
402 template <
typename _Obj>
408 return { {
__res.first,
this },
__res.second };
411 template <
typename _Obj>
419 _Base::insert_or_assign(
__hint.base(),
__k,
425 template <
typename _Obj>
439#if __cplusplus > 201402L
440 using node_type =
typename _Base::node_type;
461 insert(node_type&&
__nh)
478#if __cplusplus >= 201103L
494 _GLIBCXX_ABI_TAG_CXX11
522#if __cplusplus >= 201103L
532 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::cend(),
533 _M_message(__gnu_debug::__msg_valid_range)
534 ._M_iterator(__first,
"first")
535 ._M_iterator(__last,
"last"));
539 return { _Base::erase(__first.base(), __last.
base()),
this };
551 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::end(),
552 _M_message(__gnu_debug::__msg_valid_range)
553 ._M_iterator(__first,
"first")
554 ._M_iterator(__last,
"last"));
557 _Base::erase(__first.base(), __last.
base());
572 this->_M_invalidate_all();
577 using _Base::key_comp;
578 using _Base::value_comp;
583 {
return iterator(_Base::find(__x),
this); }
585#if __cplusplus > 201103L
586 template<
typename _Kt,
588 typename __has_is_transparent<_Compare, _Kt>::type>
591 {
return { _Base::find(__x),
this }; }
598#if __cplusplus > 201103L
599 template<
typename _Kt,
601 typename __has_is_transparent<_Compare, _Kt>::type>
603 find(
const _Kt& __x)
const
604 {
return { _Base::find(__x),
this }; }
611 {
return iterator(_Base::lower_bound(__x),
this); }
613#if __cplusplus > 201103L
614 template<
typename _Kt,
616 typename __has_is_transparent<_Compare, _Kt>::type>
618 lower_bound(
const _Kt& __x)
619 {
return { _Base::lower_bound(__x),
this }; }
623 lower_bound(
const key_type& __x)
const
626#if __cplusplus > 201103L
627 template<
typename _Kt,
629 typename __has_is_transparent<_Compare, _Kt>::type>
631 lower_bound(
const _Kt& __x)
const
632 {
return { _Base::lower_bound(__x),
this }; }
637 {
return iterator(_Base::upper_bound(__x),
this); }
639#if __cplusplus > 201103L
640 template<
typename _Kt,
642 typename __has_is_transparent<_Compare, _Kt>::type>
644 upper_bound(
const _Kt& __x)
645 {
return { _Base::upper_bound(__x),
this }; }
649 upper_bound(
const key_type& __x)
const
652#if __cplusplus > 201103L
653 template<
typename _Kt,
655 typename __has_is_transparent<_Compare, _Kt>::type>
657 upper_bound(
const _Kt& __x)
const
658 {
return { _Base::upper_bound(__x),
this }; }
665 _Base::equal_range(__x);
670#if __cplusplus > 201103L
671 template<
typename _Kt,
673 typename __has_is_transparent<_Compare, _Kt>::type>
675 equal_range(
const _Kt& __x)
677 auto __res = _Base::equal_range(__x);
678 return { {
__res.first,
this }, {
__res.second,
this } };
683 equal_range(
const key_type& __x)
const
686 _Base::equal_range(__x);
691#if __cplusplus > 201103L
692 template<
typename _Kt,
694 typename __has_is_transparent<_Compare, _Kt>::type>
696 equal_range(
const _Kt& __x)
const
698 auto __res = _Base::equal_range(__x);
699 return { {
__res.first,
this }, {
__res.second,
this } };
710#if __cpp_deduction_guides >= 201606
723 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
724 typename _Allocator = allocator<pair<const _Key, _Tp>>,
725 typename = _RequireNotAllocator<_Compare>,
726 typename = _RequireAllocator<_Allocator>>
745 template<
typename _Key,
typename _Tp,
750 {
return __lhs._M_base() ==
__rhs._M_base(); }
752#if __cpp_lib_three_way_comparison
753 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
754 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
757 {
return __lhs._M_base() <=>
__rhs._M_base(); }
759 template<
typename _Key,
typename _Tp,
760 typename _Compare,
typename _Allocator>
762 operator!=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
763 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
764 {
return __lhs._M_base() != __rhs._M_base(); }
766 template<
typename _Key,
typename _Tp,
767 typename _Compare,
typename _Allocator>
769 operator<(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
770 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
771 {
return __lhs._M_base() < __rhs._M_base(); }
773 template<
typename _Key,
typename _Tp,
774 typename _Compare,
typename _Allocator>
776 operator<=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
777 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
778 {
return __lhs._M_base() <= __rhs._M_base(); }
780 template<
typename _Key,
typename _Tp,
781 typename _Compare,
typename _Allocator>
783 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
784 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
785 {
return __lhs._M_base() >= __rhs._M_base(); }
787 template<
typename _Key,
typename _Tp,
788 typename _Compare,
typename _Allocator>
790 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
791 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
792 {
return __lhs._M_base() > __rhs._M_base(); }
795 template<
typename _Key,
typename _Tp,
796 typename _Compare,
typename _Allocator>
798 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
799 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
800 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
801 { __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...