29#ifndef _GLIBCXX_DEBUG_MULTISET_H
30#define _GLIBCXX_DEBUG_MULTISET_H 1
37namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Key,
typename _Compare = std::less<_Key>,
43 typename _Allocator = std::allocator<_Key> >
46 multiset<_Key, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>
50 typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>
_Base;
58 template<
typename _ItT,
typename _SeqT,
typename _CatT>
59 friend class ::__gnu_debug::_Safe_iterator;
66 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
73 typedef _Key key_type;
74 typedef _Key value_type;
75 typedef _Compare key_compare;
76 typedef _Compare value_compare;
77 typedef _Allocator allocator_type;
78 typedef typename _Base::reference reference;
79 typedef typename _Base::const_reference const_reference;
86 typedef typename _Base::size_type size_type;
87 typedef typename _Base::difference_type difference_type;
88 typedef typename _Base::pointer pointer;
89 typedef typename _Base::const_pointer const_pointer;
95#if __cplusplus < 201103L
108 const _Compare& __comp = _Compare(),
109 const allocator_type& __a = allocator_type())
110 :
_Base(__l, __comp, __a) { }
117 const __type_identity_t<allocator_type>& __a)
118 :
_Base(__m, __a) { }
129 template<
typename _InputIterator>
130 multiset(_InputIterator __first, _InputIterator __last,
131 const allocator_type& __a)
133 __glibcxx_check_valid_constructor_range(__first, __last)),
139 explicit multiset(
const _Compare& __comp,
140 const _Allocator& __a = _Allocator())
141 :
_Base(__comp, __a) { }
143 template<
typename _InputIterator>
144 multiset(_InputIterator __first, _InputIterator __last,
145 const _Compare& __comp = _Compare(),
146 const _Allocator& __a = _Allocator())
148 __glibcxx_check_valid_constructor_range(__first, __last)),
153 :
_Base(__x._M_ref) { }
155#if __cplusplus >= 201103L
157 operator=(
const multiset&) =
default;
165 _Base::operator=(__l);
166 this->_M_invalidate_all();
171 using _Base::get_allocator;
175 begin() _GLIBCXX_NOEXCEPT
176 {
return iterator(_Base::begin(),
this); }
179 begin()
const _GLIBCXX_NOEXCEPT
183 end() _GLIBCXX_NOEXCEPT
184 {
return iterator(_Base::end(),
this); }
187 end()
const _GLIBCXX_NOEXCEPT
191 rbegin() _GLIBCXX_NOEXCEPT
195 rbegin()
const _GLIBCXX_NOEXCEPT
199 rend() _GLIBCXX_NOEXCEPT
203 rend()
const _GLIBCXX_NOEXCEPT
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#if __cplusplus >= 201103L
231 template<
typename... _Args>
233 emplace(_Args&&... __args)
234 {
return { _Base::emplace(std::forward<_Args>(__args)...),
this }; }
236 template<
typename... _Args>
243 _Base::emplace_hint(__pos.
base(), std::forward<_Args>(__args)...),
250 insert(
const value_type& __x)
251 {
return iterator(_Base::insert(__x),
this); }
253#if __cplusplus >= 201103L
255 insert(value_type&& __x)
256 {
return { _Base::insert(
std::move(__x)),
this }; }
263 return iterator(_Base::insert(__position.
base(), __x),
this);
266#if __cplusplus >= 201103L
271 return { _Base::insert(__position.
base(),
std::move(__x)),
this };
275 template<
typename _InputIterator>
277 insert(_InputIterator __first, _InputIterator __last)
280 __glibcxx_check_valid_range2(__first, __last, __dist);
282 if (__dist.
second >= __gnu_debug::__dp_sign)
283 _Base::insert(__gnu_debug::__unsafe(__first),
284 __gnu_debug::__unsafe(__last));
286 _Base::insert(__first, __last);
289#if __cplusplus >= 201103L
292 { _Base::insert(__l); }
295#if __cplusplus > 201402L
296 using node_type =
typename _Base::node_type;
302 this->_M_invalidate_if(
_Equal(__position.
base()));
303 return _Base::extract(__position.
base());
307 extract(
const key_type& __key)
309 const auto __position = find(__key);
310 if (__position != end())
311 return extract(__position);
316 insert(node_type&& __nh)
317 {
return { _Base::insert(
std::move(__nh)),
this }; }
323 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
329#if __cplusplus >= 201103L
330 _GLIBCXX_ABI_TAG_CXX11
335 return { erase(__position.
base()),
this };
341 __glibcxx_check_erase2(__position);
342 this->_M_invalidate_if(
_Equal(__position));
343 return _Base::erase(__position);
350 this->_M_invalidate_if(
_Equal(__position.
base()));
351 _Base::erase(__position.
base());
356 erase(
const key_type& __x)
359 _Base::equal_range(__x);
360 size_type __count = 0;
362 while (__victim != __victims.
second)
364 this->_M_invalidate_if(
_Equal(__victim));
365 _Base::erase(__victim++);
371#if __cplusplus >= 201103L
372 _GLIBCXX_ABI_TAG_CXX11
380 __victim != __last.
base(); ++__victim)
382 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
383 _M_message(__gnu_debug::__msg_valid_range)
384 ._M_iterator(__first,
"first")
385 ._M_iterator(__last,
"last"));
386 this->_M_invalidate_if(
_Equal(__victim));
389 return { _Base::erase(__first.base(), __last.
base()),
this };
399 __victim != __last.
base(); ++__victim)
401 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
402 _M_message(__gnu_debug::__msg_valid_range)
403 ._M_iterator(__first,
"first")
404 ._M_iterator(__last,
"last"));
405 this->_M_invalidate_if(
_Equal(__victim));
407 _Base::erase(__first.base(), __last.
base());
413 _GLIBCXX_NOEXCEPT_IF(
noexcept(declval<_Base&>().swap(__x)) )
420 clear() _GLIBCXX_NOEXCEPT
422 this->_M_invalidate_all();
427 using _Base::key_comp;
428 using _Base::value_comp;
432 find(
const key_type& __x)
433 {
return iterator(_Base::find(__x),
this); }
438 find(
const key_type& __x)
const
441#if __cplusplus > 201103L
442 template<
typename _Kt,
444 typename __has_is_transparent<_Compare, _Kt>::type>
447 {
return { _Base::find(__x),
this }; }
449 template<
typename _Kt,
451 typename __has_is_transparent<_Compare, _Kt>::type>
453 find(
const _Kt& __x)
const
454 {
return { _Base::find(__x),
this }; }
460 lower_bound(
const key_type& __x)
461 {
return iterator(_Base::lower_bound(__x),
this); }
466 lower_bound(
const key_type& __x)
const
469#if __cplusplus > 201103L
470 template<
typename _Kt,
472 typename __has_is_transparent<_Compare, _Kt>::type>
474 lower_bound(
const _Kt& __x)
475 {
return { _Base::lower_bound(__x),
this }; }
477 template<
typename _Kt,
479 typename __has_is_transparent<_Compare, _Kt>::type>
481 lower_bound(
const _Kt& __x)
const
482 {
return { _Base::lower_bound(__x),
this }; }
486 upper_bound(
const key_type& __x)
487 {
return iterator(_Base::upper_bound(__x),
this); }
492 upper_bound(
const key_type& __x)
const
495#if __cplusplus > 201103L
496 template<
typename _Kt,
498 typename __has_is_transparent<_Compare, _Kt>::type>
500 upper_bound(
const _Kt& __x)
501 {
return { _Base::upper_bound(__x),
this }; }
503 template<
typename _Kt,
505 typename __has_is_transparent<_Compare, _Kt>::type>
507 upper_bound(
const _Kt& __x)
const
508 {
return { _Base::upper_bound(__x),
this }; }
512 equal_range(
const key_type& __x)
515 _Base::equal_range(__x);
523 equal_range(
const key_type& __x)
const
526 _Base::equal_range(__x);
531#if __cplusplus > 201103L
532 template<
typename _Kt,
534 typename __has_is_transparent<_Compare, _Kt>::type>
536 equal_range(
const _Kt& __x)
538 auto __res = _Base::equal_range(__x);
539 return { { __res.first,
this }, { __res.second,
this } };
542 template<
typename _Kt,
544 typename __has_is_transparent<_Compare, _Kt>::type>
546 equal_range(
const _Kt& __x)
const
548 auto __res = _Base::equal_range(__x);
549 return { { __res.first,
this }, { __res.second,
this } };
554 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
557 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
560#if __cpp_deduction_guides >= 201606
562 template<
typename _InputIterator,
565 typename _Allocator =
567 typename = _RequireInputIter<_InputIterator>,
568 typename = _RequireNotAllocator<_Compare>,
569 typename = _RequireAllocator<_Allocator>>
570 multiset(_InputIterator, _InputIterator,
571 _Compare = _Compare(), _Allocator = _Allocator())
573 _Compare, _Allocator>;
575 template<
typename _Key,
578 typename = _RequireNotAllocator<_Compare>,
579 typename = _RequireAllocator<_Allocator>>
581 _Compare = _Compare(), _Allocator = _Allocator())
584 template<
typename _InputIterator,
typename _Allocator,
585 typename = _RequireInputIter<_InputIterator>,
586 typename = _RequireAllocator<_Allocator>>
587 multiset(_InputIterator, _InputIterator, _Allocator)
592 template<
typename _Key,
typename _Allocator,
593 typename = _RequireAllocator<_Allocator>>
599 template<
typename _Key,
typename _Compare,
typename _Allocator>
603 {
return __lhs._M_base() == __rhs._M_base(); }
605#if __cpp_lib_three_way_comparison
606 template<
typename _Key,
typename _Compare,
typename _Alloc>
607 inline __detail::__synth3way_t<_Key>
610 {
return __lhs._M_base() <=> __rhs._M_base(); }
612 template<
typename _Key,
typename _Compare,
typename _Allocator>
614 operator!=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
615 const multiset<_Key, _Compare, _Allocator>& __rhs)
616 {
return __lhs._M_base() != __rhs._M_base(); }
618 template<
typename _Key,
typename _Compare,
typename _Allocator>
620 operator<(
const multiset<_Key, _Compare, _Allocator>& __lhs,
621 const multiset<_Key, _Compare, _Allocator>& __rhs)
622 {
return __lhs._M_base() < __rhs._M_base(); }
624 template<
typename _Key,
typename _Compare,
typename _Allocator>
626 operator<=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
627 const multiset<_Key, _Compare, _Allocator>& __rhs)
628 {
return __lhs._M_base() <= __rhs._M_base(); }
630 template<
typename _Key,
typename _Compare,
typename _Allocator>
632 operator>=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
633 const multiset<_Key, _Compare, _Allocator>& __rhs)
634 {
return __lhs._M_base() >= __rhs._M_base(); }
636 template<
typename _Key,
typename _Compare,
typename _Allocator>
638 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
639 const multiset<_Key, _Compare, _Allocator>& __rhs)
640 {
return __lhs._M_base() > __rhs._M_base(); }
643 template<
typename _Key,
typename _Compare,
typename _Allocator>
645 swap(multiset<_Key, _Compare, _Allocator>& __x,
646 multiset<_Key, _Compare, _Allocator>& __y)
647 _GLIBCXX_NOEXCEPT_IF(
noexcept(__x.swap(__y)))
648 {
return __x.swap(__y); }
#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)
The standard allocator, as per C++03 [20.4.1].
_Iterator & base() noexcept
Return the underlying iterator.
One of the comparison functors.
Struct holding two objects of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.
A standard container made up of elements, which can be retrieved in logarithmic time.
Class std::multiset 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...