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;
63 typedef _Key key_type;
64 typedef _Key value_type;
65 typedef _Compare key_compare;
66 typedef _Compare value_compare;
67 typedef _Allocator allocator_type;
68 typedef typename _Base::reference reference;
69 typedef typename _Base::const_reference const_reference;
76 typedef typename _Base::size_type size_type;
77 typedef typename _Base::difference_type difference_type;
78 typedef typename _Base::pointer pointer;
79 typedef typename _Base::const_pointer const_pointer;
85 #if __cplusplus < 201103L 98 const _Compare& __comp = _Compare(),
99 const allocator_type& __a = allocator_type())
100 :
_Base(__l, __comp, __a) { }
107 :
_Base(__m, __a) { }
110 noexcept( noexcept(
_Base(std::move(__m._M_base()), __a)) )
111 :
_Safe(std::move(__m._M_safe()), __a),
112 _Base(std::move(__m._M_base()), __a) { }
118 template<
typename _InputIterator>
119 multiset(_InputIterator __first, _InputIterator __last,
120 const allocator_type& __a)
122 __glibcxx_check_valid_constructor_range(__first, __last)),
128 explicit multiset(
const _Compare& __comp,
129 const _Allocator& __a = _Allocator())
130 :
_Base(__comp, __a) { }
132 template<
typename _InputIterator>
133 multiset(_InputIterator __first, _InputIterator __last,
134 const _Compare& __comp = _Compare(),
135 const _Allocator& __a = _Allocator())
137 __glibcxx_check_valid_constructor_range(__first, __last)),
144 #if __cplusplus < 201103L 148 this->_M_safe() = __x;
154 operator=(
const multiset&) =
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
180 end() _GLIBCXX_NOEXCEPT
181 {
return iterator(_Base::end(),
this); }
184 end()
const _GLIBCXX_NOEXCEPT
188 rbegin() _GLIBCXX_NOEXCEPT
192 rbegin()
const _GLIBCXX_NOEXCEPT
196 rend() _GLIBCXX_NOEXCEPT
200 rend()
const _GLIBCXX_NOEXCEPT
203 #if __cplusplus >= 201103L 205 cbegin()
const noexcept
209 cend()
const noexcept
213 crbegin()
const noexcept
217 crend()
const noexcept
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>
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 252 insert(value_type&& __x)
253 {
return { _Base::insert(std::move(__x)),
this }; }
260 return iterator(_Base::insert(__position.
base(), __x),
this);
263 #if __cplusplus >= 201103L 268 return { _Base::insert(__position.
base(), std::move(__x)),
this };
272 template<
typename _InputIterator>
274 insert(_InputIterator __first, _InputIterator __last)
277 __glibcxx_check_valid_range2(__first, __last, __dist);
279 if (__dist.
second >= __gnu_debug::__dp_sign)
280 _Base::insert(__gnu_debug::__unsafe(__first),
281 __gnu_debug::__unsafe(__last));
283 _Base::insert(__first, __last);
286 #if __cplusplus >= 201103L 289 { _Base::insert(__l); }
292 #if __cplusplus > 201402L 293 using node_type =
typename _Base::node_type;
300 return _Base::extract(__position.
base());
304 extract(
const key_type& __key)
306 const auto __position = find(__key);
307 if (__position != end())
308 return extract(__position);
313 insert(node_type&& __nh)
314 {
return { _Base::insert(std::move(__nh)),
this }; }
320 return { _Base::insert(__hint.
base(), std::move(__nh)),
this };
326 #if __cplusplus >= 201103L 327 _GLIBCXX_ABI_TAG_CXX11
333 return { _Base::erase(__position.
base()),
this };
341 _Base::erase(__position.
base());
346 erase(
const key_type& __x)
349 _Base::equal_range(__x);
350 size_type __count = 0;
352 while (__victim != __victims.
second)
355 _Base::erase(__victim++);
361 #if __cplusplus >= 201103L 362 _GLIBCXX_ABI_TAG_CXX11
370 __victim != __last.
base(); ++__victim)
372 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
373 _M_message(__gnu_debug::__msg_valid_range)
374 ._M_iterator(__first,
"first")
375 ._M_iterator(__last,
"last"));
379 return { _Base::erase(__first.
base(), __last.
base()),
this };
389 __victim != __last.
base(); ++__victim)
391 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
392 _M_message(__gnu_debug::__msg_valid_range)
393 ._M_iterator(__first,
"first")
394 ._M_iterator(__last,
"last"));
397 _Base::erase(__first.
base(), __last.
base());
403 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
410 clear() _GLIBCXX_NOEXCEPT
412 this->_M_invalidate_all();
417 using _Base::key_comp;
418 using _Base::value_comp;
422 find(
const key_type& __x)
423 {
return iterator(_Base::find(__x),
this); }
428 find(
const key_type& __x)
const 431 #if __cplusplus > 201103L 432 template<
typename _Kt,
434 typename __has_is_transparent<_Compare, _Kt>::type>
437 {
return { _Base::find(__x),
this }; }
439 template<
typename _Kt,
441 typename __has_is_transparent<_Compare, _Kt>::type>
443 find(
const _Kt& __x)
const 444 {
return { _Base::find(__x),
this }; }
450 lower_bound(
const key_type& __x)
451 {
return iterator(_Base::lower_bound(__x),
this); }
456 lower_bound(
const key_type& __x)
const 459 #if __cplusplus > 201103L 460 template<
typename _Kt,
462 typename __has_is_transparent<_Compare, _Kt>::type>
464 lower_bound(
const _Kt& __x)
465 {
return { _Base::lower_bound(__x),
this }; }
467 template<
typename _Kt,
469 typename __has_is_transparent<_Compare, _Kt>::type>
471 lower_bound(
const _Kt& __x)
const 472 {
return { _Base::lower_bound(__x),
this }; }
476 upper_bound(
const key_type& __x)
477 {
return iterator(_Base::upper_bound(__x),
this); }
482 upper_bound(
const key_type& __x)
const 485 #if __cplusplus > 201103L 486 template<
typename _Kt,
488 typename __has_is_transparent<_Compare, _Kt>::type>
490 upper_bound(
const _Kt& __x)
491 {
return { _Base::upper_bound(__x),
this }; }
493 template<
typename _Kt,
495 typename __has_is_transparent<_Compare, _Kt>::type>
497 upper_bound(
const _Kt& __x)
const 498 {
return { _Base::upper_bound(__x),
this }; }
502 equal_range(
const key_type& __x)
505 _Base::equal_range(__x);
513 equal_range(
const key_type& __x)
const 516 _Base::equal_range(__x);
521 #if __cplusplus > 201103L 522 template<
typename _Kt,
524 typename __has_is_transparent<_Compare, _Kt>::type>
526 equal_range(
const _Kt& __x)
528 auto __res = _Base::equal_range(__x);
529 return { { __res.first,
this }, { __res.second,
this } };
532 template<
typename _Kt,
534 typename __has_is_transparent<_Compare, _Kt>::type>
536 equal_range(
const _Kt& __x)
const 538 auto __res = _Base::equal_range(__x);
539 return { { __res.first,
this }, { __res.second,
this } };
544 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
547 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
550 #if __cpp_deduction_guides >= 201606 552 template<
typename _InputIterator,
555 typename _Allocator =
557 typename = _RequireInputIter<_InputIterator>,
558 typename = _RequireNotAllocator<_Compare>,
559 typename = _RequireAllocator<_Allocator>>
560 multiset(_InputIterator, _InputIterator,
561 _Compare = _Compare(), _Allocator = _Allocator())
563 _Compare, _Allocator>;
565 template<
typename _Key,
568 typename = _RequireNotAllocator<_Compare>,
569 typename = _RequireAllocator<_Allocator>>
571 _Compare = _Compare(), _Allocator = _Allocator())
574 template<
typename _InputIterator,
typename _Allocator,
575 typename = _RequireInputIter<_InputIterator>,
576 typename = _RequireAllocator<_Allocator>>
577 multiset(_InputIterator, _InputIterator, _Allocator)
582 template<
typename _Key,
typename _Allocator,
583 typename = _RequireAllocator<_Allocator>>
589 template<
typename _Key,
typename _Compare,
typename _Allocator>
593 {
return __lhs._M_base() == __rhs._M_base(); }
595 template<
typename _Key,
typename _Compare,
typename _Allocator>
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 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
622 const multiset<_Key, _Compare, _Allocator>& __rhs)
623 {
return __lhs._M_base() > __rhs._M_base(); }
625 template<
typename _Key,
typename _Compare,
typename _Allocator>
627 swap(multiset<_Key, _Compare, _Allocator>& __x,
628 multiset<_Key, _Compare, _Allocator>& __y)
629 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
630 {
return __x.swap(__y); }
Class std::multiset with safety/checking/debug instrumentation.
_T2 second
first is a copy of the first object
A standard container made up of elements, which can be retrieved in logarithmic time.
ISO C++ entities toplevel namespace is std.
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
The standard allocator, as per [20.4].
#define __glibcxx_check_erase_range(_First, _Last)
void _M_invalidate_if(_Predicate __pred)
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_erase(_Position)
#define __glibcxx_check_insert(_Position)
One of the comparison functors.
Struct holding two objects of arbitrary type.
_Iterator & base() noexcept
Return the underlying iterator.
_Iterator __base(_Iterator __it)
Safe class dealing with some allocator dependent operations.