29 #ifndef _GLIBCXX_DEBUG_MULTISET_H
30 #define _GLIBCXX_DEBUG_MULTISET_H 1
37 namespace 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)),
136 #if __glibcxx_containers_ranges
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
142 multiset(std::from_range_t __t, _Rg&& __rg,
144 const allocator_type& __a = allocator_type())
145 :
_Base(__t, std::forward<_Rg>(__rg), __c, __a)
148 template<std::__detail::__container_compatible_range<value_type> _Rg>
149 multiset(std::from_range_t __t, _Rg&& __rg,
150 const allocator_type& __a = allocator_type())
151 :
_Base(__t, std::forward<_Rg>(__rg), __a)
158 explicit multiset(
const _Compare& __comp,
159 const _Allocator& __a = _Allocator())
160 :
_Base(__comp, __a) { }
162 template<
typename _InputIterator>
163 multiset(_InputIterator __first, _InputIterator __last,
164 const _Compare& __comp = _Compare(),
165 const _Allocator& __a = _Allocator())
167 __glibcxx_check_valid_constructor_range(__first, __last)),
172 :
_Base(__x._M_ref) { }
174 #if __cplusplus >= 201103L
176 operator=(
const multiset&) =
default;
184 _Base::operator=(__l);
185 this->_M_invalidate_all();
190 using _Base::get_allocator;
194 begin() _GLIBCXX_NOEXCEPT
195 {
return iterator(_Base::begin(),
this); }
198 begin()
const _GLIBCXX_NOEXCEPT
202 end() _GLIBCXX_NOEXCEPT
203 {
return iterator(_Base::end(),
this); }
206 end()
const _GLIBCXX_NOEXCEPT
210 rbegin() _GLIBCXX_NOEXCEPT
214 rbegin()
const _GLIBCXX_NOEXCEPT
218 rend() _GLIBCXX_NOEXCEPT
222 rend()
const _GLIBCXX_NOEXCEPT
225 #if __cplusplus >= 201103L
227 cbegin()
const noexcept
231 cend()
const noexcept
235 crbegin()
const noexcept
239 crend()
const noexcept
246 using _Base::max_size;
249 #if __cplusplus >= 201103L
250 template<
typename... _Args>
252 emplace(_Args&&... __args)
253 {
return { _Base::emplace(std::forward<_Args>(__args)...),
this }; }
255 template<
typename... _Args>
262 _Base::emplace_hint(__pos.
base(), std::forward<_Args>(__args)...),
269 insert(
const value_type& __x)
270 {
return iterator(_Base::insert(__x),
this); }
272 #if __cplusplus >= 201103L
274 insert(value_type&& __x)
275 {
return { _Base::insert(
std::move(__x)),
this }; }
282 return iterator(_Base::insert(__position.
base(), __x),
this);
285 #if __cplusplus >= 201103L
290 return { _Base::insert(__position.
base(),
std::move(__x)),
this };
294 template<
typename _InputIterator>
296 insert(_InputIterator __first, _InputIterator __last)
299 __glibcxx_check_valid_range2(__first, __last, __dist);
301 if (__dist.
second >= __gnu_debug::__dp_sign)
302 _Base::insert(__gnu_debug::__unsafe(__first),
303 __gnu_debug::__unsafe(__last));
305 _Base::insert(__first, __last);
308 #if __cplusplus >= 201103L
311 { _Base::insert(__l); }
314 #ifdef __glibcxx_node_extract
315 using node_type =
typename _Base::node_type;
322 return _Base::extract(__position.
base());
326 extract(
const key_type& __key)
328 const auto __position = find(__key);
329 if (__position != end())
330 return extract(__position);
334 # ifdef __glibcxx_associative_heterogeneous_erasure
335 template <__heterogeneous_tree_key<multiset> _Kt>
339 const auto __position = find(__key);
340 if (__position != end())
341 return extract(__position);
347 insert(node_type&& __nh)
348 {
return { _Base::insert(
std::move(__nh)),
this }; }
354 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
360 #if __cplusplus >= 201103L
361 _GLIBCXX_ABI_TAG_CXX11
366 return { erase(__position.
base()),
this };
372 __glibcxx_check_erase2(__position);
374 return _Base::erase(__position);
382 _Base::erase(__position.
base());
387 erase(
const key_type& __x)
390 _Base::equal_range(__x);
391 size_type __count = 0;
393 while (__victim != __victims.
second)
396 _Base::erase(__victim++);
402 # ifdef __glibcxx_associative_heterogeneous_erasure
403 template <__heterogeneous_tree_key<multiset> _Kt>
407 auto __victims = _Base::equal_range(__x);
408 size_type __count = 0;
409 for (
auto __victim = __victims.first; __victim != __victims.second;)
412 _Base::erase(__victim++);
419 #if __cplusplus >= 201103L
420 _GLIBCXX_ABI_TAG_CXX11
428 __victim != __last.
base(); ++__victim)
430 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
431 _M_message(__gnu_debug::__msg_valid_range)
432 ._M_iterator(__first,
"first")
433 ._M_iterator(__last,
"last"));
437 return { _Base::erase(__first.base(), __last.
base()),
this };
447 __victim != __last.
base(); ++__victim)
449 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
450 _M_message(__gnu_debug::__msg_valid_range)
451 ._M_iterator(__first,
"first")
452 ._M_iterator(__last,
"last"));
455 _Base::erase(__first.base(), __last.
base());
461 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
468 clear() _GLIBCXX_NOEXCEPT
470 this->_M_invalidate_all();
475 using _Base::key_comp;
476 using _Base::value_comp;
480 find(
const key_type& __x)
481 {
return iterator(_Base::find(__x),
this); }
486 find(
const key_type& __x)
const
489 #ifdef __glibcxx_generic_associative_lookup
490 template<
typename _Kt,
492 typename __has_is_transparent<_Compare, _Kt>::type>
495 {
return { _Base::find(__x),
this }; }
497 template<
typename _Kt,
499 typename __has_is_transparent<_Compare, _Kt>::type>
501 find(
const _Kt& __x)
const
502 {
return { _Base::find(__x),
this }; }
508 lower_bound(
const key_type& __x)
509 {
return iterator(_Base::lower_bound(__x),
this); }
514 lower_bound(
const key_type& __x)
const
517 #ifdef __glibcxx_generic_associative_lookup
518 template<
typename _Kt,
520 typename __has_is_transparent<_Compare, _Kt>::type>
522 lower_bound(
const _Kt& __x)
523 {
return { _Base::lower_bound(__x),
this }; }
525 template<
typename _Kt,
527 typename __has_is_transparent<_Compare, _Kt>::type>
529 lower_bound(
const _Kt& __x)
const
530 {
return { _Base::lower_bound(__x),
this }; }
534 upper_bound(
const key_type& __x)
535 {
return iterator(_Base::upper_bound(__x),
this); }
540 upper_bound(
const key_type& __x)
const
543 #ifdef __glibcxx_generic_associative_lookup
544 template<
typename _Kt,
546 typename __has_is_transparent<_Compare, _Kt>::type>
548 upper_bound(
const _Kt& __x)
549 {
return { _Base::upper_bound(__x),
this }; }
551 template<
typename _Kt,
553 typename __has_is_transparent<_Compare, _Kt>::type>
555 upper_bound(
const _Kt& __x)
const
556 {
return { _Base::upper_bound(__x),
this }; }
560 equal_range(
const key_type& __x)
563 _Base::equal_range(__x);
571 equal_range(
const key_type& __x)
const
574 _Base::equal_range(__x);
579 #ifdef __glibcxx_generic_associative_lookup
580 template<
typename _Kt,
582 typename __has_is_transparent<_Compare, _Kt>::type>
584 equal_range(
const _Kt& __x)
586 auto __res = _Base::equal_range(__x);
587 return { { __res.first,
this }, { __res.second,
this } };
590 template<
typename _Kt,
592 typename __has_is_transparent<_Compare, _Kt>::type>
594 equal_range(
const _Kt& __x)
const
596 auto __res = _Base::equal_range(__x);
597 return { { __res.first,
this }, { __res.second,
this } };
602 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
605 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
608 #if __cpp_deduction_guides >= 201606
610 template<
typename _InputIterator,
613 typename _Allocator =
615 typename = _RequireInputIter<_InputIterator>,
616 typename = _RequireNotAllocator<_Compare>,
617 typename = _RequireAllocator<_Allocator>>
618 multiset(_InputIterator, _InputIterator,
619 _Compare = _Compare(), _Allocator = _Allocator())
621 _Compare, _Allocator>;
623 template<
typename _Key,
626 typename = _RequireNotAllocator<_Compare>,
627 typename = _RequireAllocator<_Allocator>>
629 _Compare = _Compare(), _Allocator = _Allocator())
632 template<
typename _InputIterator,
typename _Allocator,
633 typename = _RequireInputIter<_InputIterator>,
634 typename = _RequireAllocator<_Allocator>>
635 multiset(_InputIterator, _InputIterator, _Allocator)
640 template<
typename _Key,
typename _Allocator,
641 typename = _RequireAllocator<_Allocator>>
645 #if __glibcxx_containers_ranges
646 template<ranges::input_range _Rg,
649 multiset(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
652 template<ranges::input_range _Rg, __allocator_like _Alloc>
653 multiset(from_range_t, _Rg&&, _Alloc)
658 template<
typename _Key,
typename _Compare,
typename _Allocator>
662 {
return __lhs._M_base() == __rhs._M_base(); }
664 #if __cpp_lib_three_way_comparison
665 template<
typename _Key,
typename _Compare,
typename _Alloc>
666 inline __detail::__synth3way_t<_Key>
669 {
return __lhs._M_base() <=> __rhs._M_base(); }
671 template<
typename _Key,
typename _Compare,
typename _Allocator>
673 operator!=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
674 const multiset<_Key, _Compare, _Allocator>& __rhs)
675 {
return __lhs._M_base() != __rhs._M_base(); }
677 template<
typename _Key,
typename _Compare,
typename _Allocator>
679 operator<(
const multiset<_Key, _Compare, _Allocator>& __lhs,
680 const multiset<_Key, _Compare, _Allocator>& __rhs)
681 {
return __lhs._M_base() < __rhs._M_base(); }
683 template<
typename _Key,
typename _Compare,
typename _Allocator>
685 operator<=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
686 const multiset<_Key, _Compare, _Allocator>& __rhs)
687 {
return __lhs._M_base() <= __rhs._M_base(); }
689 template<
typename _Key,
typename _Compare,
typename _Allocator>
691 operator>=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
692 const multiset<_Key, _Compare, _Allocator>& __rhs)
693 {
return __lhs._M_base() >= __rhs._M_base(); }
695 template<
typename _Key,
typename _Compare,
typename _Allocator>
697 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
698 const multiset<_Key, _Compare, _Allocator>& __rhs)
699 {
return __lhs._M_base() > __rhs._M_base(); }
702 template<
typename _Key,
typename _Compare,
typename _Allocator>
704 swap(multiset<_Key, _Compare, _Allocator>& __x,
705 multiset<_Key, _Compare, _Allocator>& __y)
706 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
707 {
return __x.swap(__y); }
#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)
The standard allocator, as per C++03 [20.4.1].
constexpr _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.
constexpr void _M_invalidate_if(_Predicate __pred) const
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...