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 :
_Safe(std::move(__m._M_safe()), __a),
108 _Base(std::move(__m._M_base()), __a) { }
114 template<
typename _InputIterator>
115 multiset(_InputIterator __first, _InputIterator __last,
116 const allocator_type& __a)
117 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
119 __gnu_debug::__base(__last), __a) { }
124 explicit multiset(
const _Compare& __comp,
125 const _Allocator& __a = _Allocator())
126 :
_Base(__comp, __a) { }
128 template<
typename _InputIterator>
129 multiset(_InputIterator __first, _InputIterator __last,
130 const _Compare& __comp = _Compare(),
131 const _Allocator& __a = _Allocator())
132 :
_Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
134 __gnu_debug::__base(__last),
140 #if __cplusplus < 201103L
144 this->_M_safe() = __x;
150 operator=(
const multiset&) =
default;
159 this->_M_invalidate_all();
164 using _Base::get_allocator;
168 begin() _GLIBCXX_NOEXCEPT
169 {
return iterator(_Base::begin(),
this); }
172 begin()
const _GLIBCXX_NOEXCEPT
176 end() _GLIBCXX_NOEXCEPT
177 {
return iterator(_Base::end(),
this); }
180 end()
const _GLIBCXX_NOEXCEPT
184 rbegin() _GLIBCXX_NOEXCEPT
188 rbegin()
const _GLIBCXX_NOEXCEPT
192 rend() _GLIBCXX_NOEXCEPT
196 rend()
const _GLIBCXX_NOEXCEPT
199 #if __cplusplus >= 201103L
201 cbegin()
const noexcept
205 cend()
const noexcept
209 crbegin()
const noexcept
213 crend()
const noexcept
220 using _Base::max_size;
223 #if __cplusplus >= 201103L
224 template<
typename... _Args>
226 emplace(_Args&&... __args)
228 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
232 template<
typename... _Args>
238 std::forward<_Args>(__args)...),
244 insert(
const value_type& __x)
245 {
return iterator(_Base::insert(__x),
this); }
247 #if __cplusplus >= 201103L
249 insert(value_type&& __x)
250 {
return iterator(_Base::insert(std::move(__x)),
this); }
257 return iterator(_Base::insert(__position.
base(), __x),
this);
260 #if __cplusplus >= 201103L
265 return iterator(_Base::insert(__position.
base(), std::move(__x)),
270 template<
typename _InputIterator>
272 insert(_InputIterator __first, _InputIterator __last)
275 __glibcxx_check_valid_range2(__first, __last, __dist);
277 if (__dist.
second >= __gnu_debug::__dp_sign)
278 _Base::insert(__gnu_debug::__unsafe(__first),
279 __gnu_debug::__unsafe(__last));
281 _Base::insert(__first, __last);
284 #if __cplusplus >= 201103L
287 { _Base::insert(__l); }
290 #if __cplusplus >= 201103L
304 _Base::erase(__position.
base());
309 erase(
const key_type& __x)
312 _Base::equal_range(__x);
313 size_type __count = 0;
315 while (__victim != __victims.
second)
318 _Base::erase(__victim++);
324 #if __cplusplus >= 201103L
332 __victim != __last.
base(); ++__victim)
334 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
335 _M_message(__gnu_debug::__msg_valid_range)
336 ._M_iterator(__first,
"first")
337 ._M_iterator(__last,
"last"));
350 __victim != __last.
base(); ++__victim)
352 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
353 _M_message(__gnu_debug::__msg_valid_range)
354 ._M_iterator(__first,
"first")
355 ._M_iterator(__last,
"last"));
358 _Base::erase(__first.
base(), __last.
base());
364 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().
swap(__x)) )
371 clear() _GLIBCXX_NOEXCEPT
373 this->_M_invalidate_all();
378 using _Base::key_comp;
379 using _Base::value_comp;
383 find(
const key_type& __x)
384 {
return iterator(_Base::find(__x),
this); }
389 find(
const key_type& __x)
const
392 #if __cplusplus > 201103L
393 template<
typename _Kt,
395 typename __has_is_transparent<_Compare, _Kt>::type>
398 {
return { _Base::find(__x),
this }; }
400 template<
typename _Kt,
402 typename __has_is_transparent<_Compare, _Kt>::type>
404 find(
const _Kt& __x)
const
405 {
return { _Base::find(__x),
this }; }
411 lower_bound(
const key_type& __x)
412 {
return iterator(_Base::lower_bound(__x),
this); }
417 lower_bound(
const key_type& __x)
const
420 #if __cplusplus > 201103L
421 template<
typename _Kt,
423 typename __has_is_transparent<_Compare, _Kt>::type>
425 lower_bound(
const _Kt& __x)
426 {
return { _Base::lower_bound(__x),
this }; }
428 template<
typename _Kt,
430 typename __has_is_transparent<_Compare, _Kt>::type>
432 lower_bound(
const _Kt& __x)
const
433 {
return { _Base::lower_bound(__x),
this }; }
437 upper_bound(
const key_type& __x)
438 {
return iterator(_Base::upper_bound(__x),
this); }
443 upper_bound(
const key_type& __x)
const
446 #if __cplusplus > 201103L
447 template<
typename _Kt,
449 typename __has_is_transparent<_Compare, _Kt>::type>
451 upper_bound(
const _Kt& __x)
452 {
return { _Base::upper_bound(__x),
this }; }
454 template<
typename _Kt,
456 typename __has_is_transparent<_Compare, _Kt>::type>
458 upper_bound(
const _Kt& __x)
const
459 {
return { _Base::upper_bound(__x),
this }; }
463 equal_range(
const key_type& __x)
466 _Base::equal_range(__x);
474 equal_range(
const key_type& __x)
const
477 _Base::equal_range(__x);
482 #if __cplusplus > 201103L
483 template<
typename _Kt,
485 typename __has_is_transparent<_Compare, _Kt>::type>
487 equal_range(
const _Kt& __x)
489 auto __res = _Base::equal_range(__x);
490 return { { __res.first,
this }, { __res.second,
this } };
493 template<
typename _Kt,
495 typename __has_is_transparent<_Compare, _Kt>::type>
497 equal_range(
const _Kt& __x)
const
499 auto __res = _Base::equal_range(__x);
500 return { { __res.first,
this }, { __res.second,
this } };
505 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
508 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
511 template<
typename _Key,
typename _Compare,
typename _Allocator>
515 {
return __lhs._M_base() == __rhs._M_base(); }
517 template<
typename _Key,
typename _Compare,
typename _Allocator>
521 {
return __lhs._M_base() != __rhs._M_base(); }
523 template<
typename _Key,
typename _Compare,
typename _Allocator>
525 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
526 const multiset<_Key, _Compare, _Allocator>& __rhs)
527 {
return __lhs._M_base() < __rhs._M_base(); }
529 template<
typename _Key,
typename _Compare,
typename _Allocator>
531 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
532 const multiset<_Key, _Compare, _Allocator>& __rhs)
533 {
return __lhs._M_base() <= __rhs._M_base(); }
535 template<
typename _Key,
typename _Compare,
typename _Allocator>
537 operator>=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
538 const multiset<_Key, _Compare, _Allocator>& __rhs)
539 {
return __lhs._M_base() >= __rhs._M_base(); }
541 template<
typename _Key,
typename _Compare,
typename _Allocator>
543 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
544 const multiset<_Key, _Compare, _Allocator>& __rhs)
545 {
return __lhs._M_base() > __rhs._M_base(); }
547 template<
typename _Key,
typename _Compare,
typename _Allocator>
549 swap(multiset<_Key, _Compare, _Allocator>& __x,
550 multiset<_Key, _Compare, _Allocator>& __y)
551 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
552 {
return __x.swap(__y); }
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
A standard container made up of elements, which can be retrieved in logarithmic time.
#define __glibcxx_check_erase(_Position)
#define __glibcxx_check_insert(_Position)
_Iterator & base() noexcept
Return the underlying iterator.
Safe class dealing with some allocator dependent operations.
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_range(_First, _Last)
void swap(basic_filebuf< _CharT, _Traits > &__x, basic_filebuf< _CharT, _Traits > &__y)
Swap specialization for filebufs.
_T2 second
first is a copy of the first object
Struct holding two objects of arbitrary type.
Class std::multiset with safety/checking/debug instrumentation.
_T1 first
second_type is the second bound type