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;
60 typedef _Key key_type;
61 typedef _Key value_type;
62 typedef _Compare key_compare;
63 typedef _Compare value_compare;
64 typedef _Allocator allocator_type;
65 typedef typename _Base::reference reference;
66 typedef typename _Base::const_reference const_reference;
73 typedef typename _Base::size_type size_type;
74 typedef typename _Base::difference_type difference_type;
75 typedef typename _Base::pointer pointer;
76 typedef typename _Base::const_pointer const_pointer;
82 #if __cplusplus < 201103L 95 const _Compare& __comp = _Compare(),
96 const allocator_type& __a = allocator_type())
97 :
_Base(__l, __comp, __a) { }
104 :
_Base(__m, __a) { }
107 noexcept( noexcept(
_Base(std::move(__m._M_base()), __a)) )
108 :
_Safe(std::move(__m._M_safe()), __a),
109 _Base(std::move(__m._M_base()), __a) { }
115 template<
typename _InputIterator>
116 multiset(_InputIterator __first, _InputIterator __last,
117 const allocator_type& __a)
118 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
120 __gnu_debug::__base(__last), __a) { }
125 explicit multiset(
const _Compare& __comp,
126 const _Allocator& __a = _Allocator())
127 :
_Base(__comp, __a) { }
129 template<
typename _InputIterator>
130 multiset(_InputIterator __first, _InputIterator __last,
131 const _Compare& __comp = _Compare(),
132 const _Allocator& __a = _Allocator())
133 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
135 __gnu_debug::__base(__last),
141 #if __cplusplus < 201103L 145 this->_M_safe() = __x;
151 operator=(
const multiset&) =
default;
160 this->_M_invalidate_all();
165 using _Base::get_allocator;
169 begin() _GLIBCXX_NOEXCEPT
170 {
return iterator(_Base::begin(),
this); }
173 begin()
const _GLIBCXX_NOEXCEPT
177 end() _GLIBCXX_NOEXCEPT
178 {
return iterator(_Base::end(),
this); }
181 end()
const _GLIBCXX_NOEXCEPT
185 rbegin() _GLIBCXX_NOEXCEPT
189 rbegin()
const _GLIBCXX_NOEXCEPT
193 rend() _GLIBCXX_NOEXCEPT
197 rend()
const _GLIBCXX_NOEXCEPT
200 #if __cplusplus >= 201103L 202 cbegin()
const noexcept
206 cend()
const noexcept
210 crbegin()
const noexcept
214 crend()
const noexcept
221 using _Base::max_size;
224 #if __cplusplus >= 201103L 225 template<
typename... _Args>
227 emplace(_Args&&... __args)
229 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
233 template<
typename... _Args>
239 std::forward<_Args>(__args)...),
245 insert(
const value_type& __x)
246 {
return iterator(_Base::insert(__x),
this); }
248 #if __cplusplus >= 201103L 250 insert(value_type&& __x)
251 {
return iterator(_Base::insert(std::move(__x)),
this); }
258 return iterator(_Base::insert(__position.
base(), __x),
this);
261 #if __cplusplus >= 201103L 266 return iterator(_Base::insert(__position.
base(), std::move(__x)),
271 template<
typename _InputIterator>
273 insert(_InputIterator __first, _InputIterator __last)
276 __glibcxx_check_valid_range2(__first, __last, __dist);
278 if (__dist.
second >= __gnu_debug::__dp_sign)
279 _Base::insert(__gnu_debug::__unsafe(__first),
280 __gnu_debug::__unsafe(__last));
282 _Base::insert(__first, __last);
285 #if __cplusplus >= 201103L 288 { _Base::insert(__l); }
291 #if __cplusplus > 201402L 292 using node_type =
typename _Base::node_type;
299 return _Base::extract(__position.
base());
303 extract(
const key_type& __key)
305 const auto __position = find(__key);
306 if (__position != end())
307 return extract(__position);
312 insert(node_type&& __nh)
313 {
return iterator(_Base::insert(std::move(__nh)),
this); }
319 return iterator(_Base::insert(__hint.
base(), std::move(__nh)),
this);
325 #if __cplusplus >= 201103L 339 _Base::erase(__position.
base());
344 erase(
const key_type& __x)
347 _Base::equal_range(__x);
348 size_type __count = 0;
350 while (__victim != __victims.
second)
353 _Base::erase(__victim++);
359 #if __cplusplus >= 201103L 367 __victim != __last.
base(); ++__victim)
369 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
370 _M_message(__gnu_debug::__msg_valid_range)
371 ._M_iterator(__first,
"first")
372 ._M_iterator(__last,
"last"));
385 __victim != __last.
base(); ++__victim)
387 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
388 _M_message(__gnu_debug::__msg_valid_range)
389 ._M_iterator(__first,
"first")
390 ._M_iterator(__last,
"last"));
393 _Base::erase(__first.
base(), __last.
base());
399 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
406 clear() _GLIBCXX_NOEXCEPT
408 this->_M_invalidate_all();
413 using _Base::key_comp;
414 using _Base::value_comp;
418 find(
const key_type& __x)
419 {
return iterator(_Base::find(__x),
this); }
424 find(
const key_type& __x)
const 427 #if __cplusplus > 201103L 428 template<
typename _Kt,
430 typename __has_is_transparent<_Compare, _Kt>::type>
433 {
return { _Base::find(__x),
this }; }
435 template<
typename _Kt,
437 typename __has_is_transparent<_Compare, _Kt>::type>
439 find(
const _Kt& __x)
const 440 {
return { _Base::find(__x),
this }; }
446 lower_bound(
const key_type& __x)
447 {
return iterator(_Base::lower_bound(__x),
this); }
452 lower_bound(
const key_type& __x)
const 455 #if __cplusplus > 201103L 456 template<
typename _Kt,
458 typename __has_is_transparent<_Compare, _Kt>::type>
460 lower_bound(
const _Kt& __x)
461 {
return { _Base::lower_bound(__x),
this }; }
463 template<
typename _Kt,
465 typename __has_is_transparent<_Compare, _Kt>::type>
467 lower_bound(
const _Kt& __x)
const 468 {
return { _Base::lower_bound(__x),
this }; }
472 upper_bound(
const key_type& __x)
473 {
return iterator(_Base::upper_bound(__x),
this); }
478 upper_bound(
const key_type& __x)
const 481 #if __cplusplus > 201103L 482 template<
typename _Kt,
484 typename __has_is_transparent<_Compare, _Kt>::type>
486 upper_bound(
const _Kt& __x)
487 {
return { _Base::upper_bound(__x),
this }; }
489 template<
typename _Kt,
491 typename __has_is_transparent<_Compare, _Kt>::type>
493 upper_bound(
const _Kt& __x)
const 494 {
return { _Base::upper_bound(__x),
this }; }
498 equal_range(
const key_type& __x)
501 _Base::equal_range(__x);
509 equal_range(
const key_type& __x)
const 512 _Base::equal_range(__x);
517 #if __cplusplus > 201103L 518 template<
typename _Kt,
520 typename __has_is_transparent<_Compare, _Kt>::type>
522 equal_range(
const _Kt& __x)
524 auto __res = _Base::equal_range(__x);
525 return { { __res.first,
this }, { __res.second,
this } };
528 template<
typename _Kt,
530 typename __has_is_transparent<_Compare, _Kt>::type>
532 equal_range(
const _Kt& __x)
const 534 auto __res = _Base::equal_range(__x);
535 return { { __res.first,
this }, { __res.second,
this } };
540 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
543 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
546 #if __cpp_deduction_guides >= 201606 548 template<
typename _InputIterator,
551 typename _Allocator =
553 typename = _RequireInputIter<_InputIterator>,
554 typename = _RequireAllocator<_Allocator>>
555 multiset(_InputIterator, _InputIterator,
556 _Compare = _Compare(), _Allocator = _Allocator())
558 _Compare, _Allocator>;
560 template<
typename _Key,
563 typename = _RequireAllocator<_Allocator>>
565 _Compare = _Compare(), _Allocator = _Allocator())
568 template<
typename _InputIterator,
typename _Allocator,
569 typename = _RequireInputIter<_InputIterator>,
570 typename = _RequireAllocator<_Allocator>>
571 multiset(_InputIterator, _InputIterator, _Allocator)
576 template<
typename _Key,
typename _Allocator,
577 typename = _RequireAllocator<_Allocator>>
583 template<
typename _Key,
typename _Compare,
typename _Allocator>
587 {
return __lhs._M_base() == __rhs._M_base(); }
589 template<
typename _Key,
typename _Compare,
typename _Allocator>
593 {
return __lhs._M_base() != __rhs._M_base(); }
595 template<
typename _Key,
typename _Compare,
typename _Allocator>
597 operator<(
const multiset<_Key, _Compare, _Allocator>& __lhs,
598 const multiset<_Key, _Compare, _Allocator>& __rhs)
599 {
return __lhs._M_base() < __rhs._M_base(); }
601 template<
typename _Key,
typename _Compare,
typename _Allocator>
603 operator<=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
604 const multiset<_Key, _Compare, _Allocator>& __rhs)
605 {
return __lhs._M_base() <= __rhs._M_base(); }
607 template<
typename _Key,
typename _Compare,
typename _Allocator>
609 operator>=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
610 const multiset<_Key, _Compare, _Allocator>& __rhs)
611 {
return __lhs._M_base() >= __rhs._M_base(); }
613 template<
typename _Key,
typename _Compare,
typename _Allocator>
615 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
616 const multiset<_Key, _Compare, _Allocator>& __rhs)
617 {
return __lhs._M_base() > __rhs._M_base(); }
619 template<
typename _Key,
typename _Compare,
typename _Allocator>
621 swap(multiset<_Key, _Compare, _Allocator>& __x,
622 multiset<_Key, _Compare, _Allocator>& __y)
623 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
624 {
return __x.swap(__y); }
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
One of the comparison functors.
Struct holding two objects of arbitrary type.
Class std::multiset with safety/checking/debug instrumentation.
A standard container made up of elements, which can be retrieved in logarithmic time.
The standard allocator, as per [20.4].
#define __glibcxx_check_erase(_Position)
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)
ISO C++ entities toplevel namespace is std.
_Iterator & base() noexcept
Return the underlying iterator.
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
_T1 first
second_type is the second bound type
_T2 second
first is a copy of the first object
Safe class dealing with some allocator dependent operations.