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& __x)
159 this->_M_safe() = __x;
165 operator=(
const map&) =
default;
168 operator=(
map&&) =
default;
174 this->_M_invalidate_all();
181 using _Base::get_allocator;
186 {
return iterator(_Base::begin(),
this); }
194 {
return iterator(_Base::end(),
this); }
216#if __cplusplus >= 201103L
218 cbegin()
const noexcept
222 cend()
const noexcept
226 crbegin()
const noexcept
230 crend()
const noexcept
237 using _Base::max_size;
240 using _Base::operator[];
247#if __cplusplus >= 201103L
248 template<
typename...
_Args>
253 return { {
__res.first,
this },
__res.second };
256 template<
typename...
_Args>
277#if __cplusplus >= 201103L
284 return { {
__res.first,
this },
__res.second };
287 template<
typename _Pair,
typename =
typename
289 _Pair&&>::value>::type>
294 return { {
__res.first,
this },
__res.second };
298#if __cplusplus >= 201103L
301 { _Base::insert(
__list); }
305#if __cplusplus >= 201103L
315#if __cplusplus >= 201103L
325 template<
typename _Pair,
typename =
typename
327 _Pair&&>::value>::type>
340 template<
typename _InputIterator>
345 __glibcxx_check_valid_range2(__first, __last,
__dist);
347 if (
__dist.second >= __gnu_debug::__dp_sign)
348 _Base::insert(__gnu_debug::__unsafe(__first),
349 __gnu_debug::__unsafe(__last));
351 _Base::insert(__first, __last);
355#if __cplusplus > 201402L
356 template <
typename...
_Args>
360 auto __res = _Base::try_emplace(
__k,
362 return { {
__res.first,
this },
__res.second };
365 template <
typename...
_Args>
371 return { {
__res.first,
this },
__res.second };
374 template <
typename...
_Args>
388 template <
typename...
_Args>
401 template <
typename _Obj>
405 auto __res = _Base::insert_or_assign(
__k,
407 return { {
__res.first,
this },
__res.second };
410 template <
typename _Obj>
416 return { {
__res.first,
this },
__res.second };
419 template <
typename _Obj>
427 _Base::insert_or_assign(
__hint.base(),
__k,
433 template <
typename _Obj>
447#if __cplusplus > 201402L
448 using node_type =
typename _Base::node_type;
469 insert(node_type&&
__nh)
486#if __cplusplus >= 201103L
492 return { _Base::erase(
__position.base()),
this };
495 _GLIBCXX_ABI_TAG_CXX11
523#if __cplusplus >= 201103L
533 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::cend(),
534 _M_message(__gnu_debug::__msg_valid_range)
535 ._M_iterator(__first,
"first")
536 ._M_iterator(__last,
"last"));
540 return { _Base::erase(__first.base(), __last.
base()),
this };
552 _GLIBCXX_DEBUG_VERIFY(
__victim != _Base::end(),
553 _M_message(__gnu_debug::__msg_valid_range)
554 ._M_iterator(__first,
"first")
555 ._M_iterator(__last,
"last"));
558 _Base::erase(__first.base(), __last.
base());
573 this->_M_invalidate_all();
578 using _Base::key_comp;
579 using _Base::value_comp;
584 {
return iterator(_Base::find(__x),
this); }
586#if __cplusplus > 201103L
587 template<
typename _Kt,
589 typename __has_is_transparent<_Compare, _Kt>::type>
592 {
return { _Base::find(__x),
this }; }
599#if __cplusplus > 201103L
600 template<
typename _Kt,
602 typename __has_is_transparent<_Compare, _Kt>::type>
604 find(
const _Kt& __x)
const
605 {
return { _Base::find(__x),
this }; }
612 {
return iterator(_Base::lower_bound(__x),
this); }
614#if __cplusplus > 201103L
615 template<
typename _Kt,
617 typename __has_is_transparent<_Compare, _Kt>::type>
619 lower_bound(
const _Kt& __x)
620 {
return { _Base::lower_bound(__x),
this }; }
624 lower_bound(
const key_type& __x)
const
627#if __cplusplus > 201103L
628 template<
typename _Kt,
630 typename __has_is_transparent<_Compare, _Kt>::type>
632 lower_bound(
const _Kt& __x)
const
633 {
return { _Base::lower_bound(__x),
this }; }
638 {
return iterator(_Base::upper_bound(__x),
this); }
640#if __cplusplus > 201103L
641 template<
typename _Kt,
643 typename __has_is_transparent<_Compare, _Kt>::type>
645 upper_bound(
const _Kt& __x)
646 {
return { _Base::upper_bound(__x),
this }; }
650 upper_bound(
const key_type& __x)
const
653#if __cplusplus > 201103L
654 template<
typename _Kt,
656 typename __has_is_transparent<_Compare, _Kt>::type>
658 upper_bound(
const _Kt& __x)
const
659 {
return { _Base::upper_bound(__x),
this }; }
666 _Base::equal_range(__x);
671#if __cplusplus > 201103L
672 template<
typename _Kt,
674 typename __has_is_transparent<_Compare, _Kt>::type>
676 equal_range(
const _Kt& __x)
678 auto __res = _Base::equal_range(__x);
679 return { {
__res.first,
this }, {
__res.second,
this } };
684 equal_range(
const key_type& __x)
const
687 _Base::equal_range(__x);
692#if __cplusplus > 201103L
693 template<
typename _Kt,
695 typename __has_is_transparent<_Compare, _Kt>::type>
697 equal_range(
const _Kt& __x)
const
699 auto __res = _Base::equal_range(__x);
700 return { {
__res.first,
this }, {
__res.second,
this } };
711#if __cpp_deduction_guides >= 201606
724 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
725 typename _Allocator = allocator<pair<const _Key, _Tp>>,
726 typename = _RequireNotAllocator<_Compare>,
727 typename = _RequireAllocator<_Allocator>>
746 template<
typename _Key,
typename _Tp,
751 {
return __lhs._M_base() ==
__rhs._M_base(); }
753#if __cpp_lib_three_way_comparison
754 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
755 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
758 {
return __lhs._M_base() <=>
__rhs._M_base(); }
760 template<
typename _Key,
typename _Tp,
761 typename _Compare,
typename _Allocator>
763 operator!=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
764 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
765 {
return __lhs._M_base() != __rhs._M_base(); }
767 template<
typename _Key,
typename _Tp,
768 typename _Compare,
typename _Allocator>
770 operator<(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
771 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
772 {
return __lhs._M_base() < __rhs._M_base(); }
774 template<
typename _Key,
typename _Tp,
775 typename _Compare,
typename _Allocator>
777 operator<=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
778 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
779 {
return __lhs._M_base() <= __rhs._M_base(); }
781 template<
typename _Key,
typename _Tp,
782 typename _Compare,
typename _Allocator>
784 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
785 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
786 {
return __lhs._M_base() >= __rhs._M_base(); }
788 template<
typename _Key,
typename _Tp,
789 typename _Compare,
typename _Allocator>
791 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
792 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
793 {
return __lhs._M_base() > __rhs._M_base(); }
796 template<
typename _Key,
typename _Tp,
797 typename _Compare,
typename _Allocator>
799 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
800 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
801 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
802 { __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.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
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...