29 #ifndef _GLIBCXX_DEBUG_MULTIMAP_H 30 #define _GLIBCXX_DEBUG_MULTIMAP_H 1 37 namespace 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 multimap<_Key, _Tp, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>
50 typedef _GLIBCXX_STD_C::multimap<
51 _Key, _Tp, _Compare, _Allocator>
_Base;
59 template<
typename _ItT,
typename _SeqT,
typename _CatT>
60 friend class ::__gnu_debug::_Safe_iterator;
64 typedef _Key key_type;
65 typedef _Tp mapped_type;
67 typedef _Compare key_compare;
68 typedef _Allocator allocator_type;
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 87 multimap() : _Base() { }
89 multimap(
const multimap& __x)
95 multimap(
const multimap&) =
default;
96 multimap(multimap&&) =
default;
99 const _Compare& __c = _Compare(),
100 const allocator_type& __a = allocator_type())
101 : _Base(__l, __c, __a) { }
104 multimap(
const allocator_type& __a)
107 multimap(
const multimap& __m,
const allocator_type& __a)
108 : _Base(__m, __a) { }
110 multimap(multimap&& __m,
const allocator_type& __a)
111 noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) )
112 : _Safe(std::move(__m._M_safe()), __a),
113 _Base(std::move(__m._M_base()), __a) { }
116 : _Base(__l, __a) { }
118 template<
typename _InputIterator>
119 multimap(_InputIterator __first, _InputIterator __last,
120 const allocator_type& __a)
122 __glibcxx_check_valid_constructor_range(__first, __last)),
125 ~multimap() =
default;
128 explicit multimap(
const _Compare& __comp,
129 const _Allocator& __a = _Allocator())
130 : _Base(__comp, __a) { }
132 template<
typename _InputIterator>
133 multimap(_InputIterator __first, _InputIterator __last,
134 const _Compare& __comp = _Compare(),
135 const _Allocator& __a = _Allocator())
137 __glibcxx_check_valid_constructor_range(__first, __last)),
141 multimap(
const _Base& __x)
144 #if __cplusplus < 201103L 146 operator=(
const multimap& __x)
148 this->_M_safe() = __x;
154 operator=(
const multimap&) =
default;
157 operator=(multimap&&) =
default;
163 this->_M_invalidate_all();
168 using _Base::get_allocator;
172 begin() _GLIBCXX_NOEXCEPT
173 {
return iterator(_Base::begin(),
this); }
176 begin()
const _GLIBCXX_NOEXCEPT
177 {
return const_iterator(_Base::begin(),
this); }
180 end() _GLIBCXX_NOEXCEPT
181 {
return iterator(_Base::end(),
this); }
184 end()
const _GLIBCXX_NOEXCEPT
185 {
return const_iterator(_Base::end(),
this); }
188 rbegin() _GLIBCXX_NOEXCEPT
189 {
return reverse_iterator(end()); }
191 const_reverse_iterator
192 rbegin()
const _GLIBCXX_NOEXCEPT
193 {
return const_reverse_iterator(end()); }
196 rend() _GLIBCXX_NOEXCEPT
197 {
return reverse_iterator(begin()); }
199 const_reverse_iterator
200 rend()
const _GLIBCXX_NOEXCEPT
201 {
return const_reverse_iterator(begin()); }
203 #if __cplusplus >= 201103L 205 cbegin()
const noexcept
206 {
return const_iterator(_Base::begin(),
this); }
209 cend()
const noexcept
210 {
return const_iterator(_Base::end(),
this); }
212 const_reverse_iterator
213 crbegin()
const noexcept
214 {
return const_reverse_iterator(end()); }
216 const_reverse_iterator
217 crend()
const noexcept
218 {
return const_reverse_iterator(begin()); }
224 using _Base::max_size;
227 #if __cplusplus >= 201103L 228 template<
typename... _Args>
230 emplace(_Args&&... __args)
231 {
return { _Base::emplace(std::forward<_Args>(__args)...),
this }; }
233 template<
typename... _Args>
235 emplace_hint(const_iterator __pos, _Args&&... __args)
240 _Base::emplace_hint(__pos.
base(), std::forward<_Args>(__args)...),
247 insert(
const value_type& __x)
248 {
return iterator(_Base::insert(__x),
this); }
250 #if __cplusplus >= 201103L 254 insert(value_type&& __x)
255 {
return { _Base::insert(std::move(__x)),
this }; }
257 template<
typename _Pair,
typename =
typename 259 _Pair&&>::value>::type>
262 {
return { _Base::insert(std::forward<_Pair>(__x)),
this }; }
265 #if __cplusplus >= 201103L 268 { _Base::insert(__list); }
272 #if __cplusplus >= 201103L 273 insert(const_iterator __position,
const value_type& __x)
275 insert(iterator __position,
const value_type& __x)
279 return iterator(_Base::insert(__position.
base(), __x),
this);
282 #if __cplusplus >= 201103L 286 insert(const_iterator __position, value_type&& __x)
289 return { _Base::insert(__position.
base(), std::move(__x)),
this };
292 template<
typename _Pair,
typename =
typename 294 _Pair&&>::value>::type>
296 insert(const_iterator __position, _Pair&& __x)
301 _Base::insert(__position.
base(), std::forward<_Pair>(__x)),
307 template<
typename _InputIterator>
309 insert(_InputIterator __first, _InputIterator __last)
312 __glibcxx_check_valid_range2(__first, __last, __dist);
314 if (__dist.
second >= __gnu_debug::__dp_sign)
315 _Base::insert(__gnu_debug::__unsafe(__first),
316 __gnu_debug::__unsafe(__last));
318 _Base::insert(__first, __last);
321 #if __cplusplus > 201402L 322 using node_type =
typename _Base::node_type;
325 extract(const_iterator __position)
329 return _Base::extract(__position.
base());
333 extract(
const key_type& __key)
335 const auto __position = find(__key);
336 if (__position != end())
337 return extract(__position);
342 insert(node_type&& __nh)
343 {
return { _Base::insert(std::move(__nh)),
this }; }
346 insert(const_iterator __hint, node_type&& __nh)
349 return { _Base::insert(__hint.
base(), std::move(__nh)),
this };
355 #if __cplusplus >= 201103L 357 erase(const_iterator __position)
361 return { _Base::erase(__position.
base()),
this };
364 _GLIBCXX_ABI_TAG_CXX11
366 erase(iterator __position)
367 {
return erase(const_iterator(__position)); }
370 erase(iterator __position)
374 _Base::erase(__position.
base());
379 erase(
const key_type& __x)
382 _Base::equal_range(__x);
383 size_type __count = 0;
384 _Base_iterator __victim = __victims.
first;
385 while (__victim != __victims.
second)
388 _Base::erase(__victim++);
394 #if __cplusplus >= 201103L 396 erase(const_iterator __first, const_iterator __last)
401 for (_Base_const_iterator __victim = __first.
base();
402 __victim != __last.
base(); ++__victim)
404 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
405 _M_message(__gnu_debug::__msg_valid_range)
406 ._M_iterator(__first,
"first")
407 ._M_iterator(__last,
"last"));
411 return { _Base::erase(__first.
base(), __last.
base()),
this };
415 erase(iterator __first, iterator __last)
420 for (_Base_iterator __victim = __first.
base();
421 __victim != __last.
base(); ++__victim)
423 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
424 _M_message(__gnu_debug::__msg_valid_range)
425 ._M_iterator(__first,
"first")
426 ._M_iterator(__last,
"last"));
429 _Base::erase(__first.
base(), __last.
base());
435 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
442 clear() _GLIBCXX_NOEXCEPT
444 this->_M_invalidate_all();
449 using _Base::key_comp;
450 using _Base::value_comp;
454 find(
const key_type& __x)
455 {
return iterator(_Base::find(__x),
this); }
457 #if __cplusplus > 201103L 458 template<
typename _Kt,
460 typename __has_is_transparent<_Compare, _Kt>::type>
463 {
return { _Base::find(__x),
this }; }
467 find(
const key_type& __x)
const 468 {
return const_iterator(_Base::find(__x),
this); }
470 #if __cplusplus > 201103L 471 template<
typename _Kt,
473 typename __has_is_transparent<_Compare, _Kt>::type>
475 find(
const _Kt& __x)
const 476 {
return { _Base::find(__x),
this }; }
482 lower_bound(
const key_type& __x)
483 {
return iterator(_Base::lower_bound(__x),
this); }
485 #if __cplusplus > 201103L 486 template<
typename _Kt,
488 typename __has_is_transparent<_Compare, _Kt>::type>
490 lower_bound(
const _Kt& __x)
491 {
return { _Base::lower_bound(__x),
this }; }
495 lower_bound(
const key_type& __x)
const 496 {
return const_iterator(_Base::lower_bound(__x),
this); }
498 #if __cplusplus > 201103L 499 template<
typename _Kt,
501 typename __has_is_transparent<_Compare, _Kt>::type>
503 lower_bound(
const _Kt& __x)
const 504 {
return { _Base::lower_bound(__x),
this }; }
508 upper_bound(
const key_type& __x)
509 {
return iterator(_Base::upper_bound(__x),
this); }
511 #if __cplusplus > 201103L 512 template<
typename _Kt,
514 typename __has_is_transparent<_Compare, _Kt>::type>
516 upper_bound(
const _Kt& __x)
517 {
return { _Base::upper_bound(__x),
this }; }
521 upper_bound(
const key_type& __x)
const 522 {
return const_iterator(_Base::upper_bound(__x),
this); }
524 #if __cplusplus > 201103L 525 template<
typename _Kt,
527 typename __has_is_transparent<_Compare, _Kt>::type>
529 upper_bound(
const _Kt& __x)
const 530 {
return { _Base::upper_bound(__x),
this }; }
534 equal_range(
const key_type& __x)
537 _Base::equal_range(__x);
539 iterator(__res.
second,
this));
542 #if __cplusplus > 201103L 543 template<
typename _Kt,
545 typename __has_is_transparent<_Compare, _Kt>::type>
547 equal_range(
const _Kt& __x)
549 auto __res = _Base::equal_range(__x);
550 return { { __res.first,
this }, { __res.second,
this } };
555 equal_range(
const key_type& __x)
const 558 _Base::equal_range(__x);
560 const_iterator(__res.
second,
this));
563 #if __cplusplus > 201103L 564 template<
typename _Kt,
566 typename __has_is_transparent<_Compare, _Kt>::type>
568 equal_range(
const _Kt& __x)
const 570 auto __res = _Base::equal_range(__x);
571 return { { __res.first,
this }, { __res.second,
this } };
576 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
579 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
582 #if __cpp_deduction_guides >= 201606 584 template<
typename _InputIterator,
587 typename = _RequireInputIter<_InputIterator>,
588 typename = _RequireNotAllocator<_Compare>,
589 typename = _RequireAllocator<_Allocator>>
590 multimap(_InputIterator, _InputIterator,
591 _Compare = _Compare(), _Allocator = _Allocator())
593 _Compare, _Allocator>;
595 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
596 typename _Allocator = allocator<pair<const _Key, _Tp>>,
597 typename = _RequireNotAllocator<_Compare>,
598 typename = _RequireAllocator<_Allocator>>
600 _Compare = _Compare(), _Allocator = _Allocator())
603 template<
typename _InputIterator,
typename _Allocator,
604 typename = _RequireInputIter<_InputIterator>,
605 typename = _RequireAllocator<_Allocator>>
606 multimap(_InputIterator, _InputIterator, _Allocator)
610 template<
typename _Key,
typename _Tp,
typename _Allocator,
611 typename = _RequireAllocator<_Allocator>>
617 template<
typename _Key,
typename _Tp,
618 typename _Compare,
typename _Allocator>
622 {
return __lhs._M_base() == __rhs._M_base(); }
624 template<
typename _Key,
typename _Tp,
625 typename _Compare,
typename _Allocator>
629 {
return __lhs._M_base() != __rhs._M_base(); }
631 template<
typename _Key,
typename _Tp,
632 typename _Compare,
typename _Allocator>
634 operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
636 {
return __lhs._M_base() < __rhs._M_base(); }
638 template<
typename _Key,
typename _Tp,
639 typename _Compare,
typename _Allocator>
641 operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
643 {
return __lhs._M_base() <= __rhs._M_base(); }
645 template<
typename _Key,
typename _Tp,
646 typename _Compare,
typename _Allocator>
650 {
return __lhs._M_base() >= __rhs._M_base(); }
652 template<
typename _Key,
typename _Tp,
653 typename _Compare,
typename _Allocator>
657 {
return __lhs._M_base() > __rhs._M_base(); }
659 template<
typename _Key,
typename _Tp,
660 typename _Compare,
typename _Allocator>
664 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
665 { __lhs.swap(__rhs); }
Class std::multimap with safety/checking/debug instrumentation.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
_T1 first
second_type is the second bound type
#define __glibcxx_check_erase_range(_First, _Last)
ISO C++ entities toplevel namespace is std.
_T2 second
first is a copy of the first object
Struct holding two objects of arbitrary type.
The standard allocator, as per [20.4].
Define a member typedef type only if a boolean constant is true.
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.
#define __glibcxx_check_insert(_Position)
_Iterator & base() noexcept
Return the underlying iterator.
void _M_invalidate_if(_Predicate __pred)
One of the comparison functors.
_Iterator __base(_Iterator __it)
Safe class dealing with some allocator dependent operations.
#define __glibcxx_check_erase(_Position)