29 #ifndef _GLIBCXX_DEBUG_MULTISET_H
30 #define _GLIBCXX_DEBUG_MULTISET_H 1
36 namespace std _GLIBCXX_VISIBILITY(default)
41 template<
typename _Key,
typename _Compare = std::less<_Key>,
42 typename _Allocator = std::allocator<_Key> >
44 :
public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>,
47 typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator>
_Base;
53 #if __cplusplus >= 201103L
59 typedef _Key key_type;
60 typedef _Key value_type;
61 typedef _Compare key_compare;
62 typedef _Compare value_compare;
63 typedef _Allocator allocator_type;
64 typedef typename _Base::reference reference;
65 typedef typename _Base::const_reference const_reference;
72 typedef typename _Base::size_type size_type;
73 typedef typename _Base::difference_type difference_type;
74 typedef typename _Base::pointer pointer;
75 typedef typename _Base::const_pointer const_pointer;
83 explicit multiset(
const _Compare& __comp,
84 const _Allocator& __a = _Allocator())
85 :
_Base(__comp, __a) { }
87 template<
typename _InputIterator>
88 multiset(_InputIterator __first, _InputIterator __last,
89 const _Compare& __comp = _Compare(),
90 const _Allocator& __a = _Allocator())
102 #if __cplusplus >= 201103L
104 noexcept(is_nothrow_copy_constructible<_Compare>::value)
105 :
_Base(std::move(__x))
109 const _Compare& __comp = _Compare(),
110 const allocator_type& __a = allocator_type())
111 :
_Base(__l, __comp, __a) { }
118 :
_Base(__m, __a) { }
121 :
_Base(std::move(__m._M_base()), __a) { }
127 template<
typename _InputIterator>
128 multiset(_InputIterator __first, _InputIterator __last,
129 const allocator_type& __a)
142 this->_M_invalidate_all();
146 #if __cplusplus >= 201103L
149 noexcept(_Alloc_traits::_S_nothrow_move())
151 __glibcxx_check_self_move_assign(__x);
152 bool xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
153 || __x.get_allocator() == this->get_allocator();
154 _M_base() = std::move(__x._M_base());
158 this->_M_invalidate_all();
159 __x._M_invalidate_all();
167 this->_M_invalidate_all();
172 using _Base::get_allocator;
176 begin() _GLIBCXX_NOEXCEPT
177 {
return iterator(_Base::begin(),
this); }
180 begin()
const _GLIBCXX_NOEXCEPT
184 end() _GLIBCXX_NOEXCEPT
185 {
return iterator(_Base::end(),
this); }
188 end()
const _GLIBCXX_NOEXCEPT
192 rbegin() _GLIBCXX_NOEXCEPT
196 rbegin()
const _GLIBCXX_NOEXCEPT
200 rend() _GLIBCXX_NOEXCEPT
204 rend()
const _GLIBCXX_NOEXCEPT
207 #if __cplusplus >= 201103L
209 cbegin()
const noexcept
213 cend()
const noexcept
217 crbegin()
const noexcept
221 crend()
const noexcept
228 using _Base::max_size;
231 #if __cplusplus >= 201103L
232 template<
typename... _Args>
234 emplace(_Args&&... __args)
236 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
239 template<
typename... _Args>
245 std::forward<_Args>(__args)...),
251 insert(
const value_type& __x)
252 {
return iterator(_Base::insert(__x),
this); }
254 #if __cplusplus >= 201103L
256 insert(value_type&& __x)
257 {
return iterator(_Base::insert(std::move(__x)),
this); }
264 return iterator(_Base::insert(__position.
base(), __x),
this);
267 #if __cplusplus >= 201103L
272 return iterator(_Base::insert(__position.
base(), std::move(__x)),
277 template<
typename _InputIterator>
279 insert(_InputIterator __first, _InputIterator __last)
281 __glibcxx_check_valid_range(__first, __last);
286 #if __cplusplus >= 201103L
289 { _Base::insert(__l); }
292 #if __cplusplus >= 201103L
306 _Base::erase(__position.
base());
311 erase(
const key_type& __x)
314 _Base::equal_range(__x);
315 size_type __count = 0;
317 while (__victim != __victims.
second)
320 _Base::erase(__victim++);
326 #if __cplusplus >= 201103L
334 __victim != __last.
base(); ++__victim)
336 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
337 _M_message(__gnu_debug::__msg_valid_range)
338 ._M_iterator(__first,
"first")
339 ._M_iterator(__last,
"last"));
352 __victim != __last.
base(); ++__victim)
354 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
355 _M_message(__gnu_debug::__msg_valid_range)
356 ._M_iterator(__first,
"first")
357 ._M_iterator(__last,
"last"));
360 _Base::erase(__first.
base(), __last.
base());
366 #if __cplusplus >= 201103L
367 noexcept(_Alloc_traits::_S_nothrow_swap())
370 #if __cplusplus >= 201103L
371 if (!_Alloc_traits::_S_propagate_on_swap())
372 __glibcxx_check_equal_allocs(__x);
379 clear() _GLIBCXX_NOEXCEPT
381 this->_M_invalidate_all();
386 using _Base::key_comp;
387 using _Base::value_comp;
391 find(
const key_type& __x)
392 {
return iterator(_Base::find(__x),
this); }
397 find(
const key_type& __x)
const
403 lower_bound(
const key_type& __x)
404 {
return iterator(_Base::lower_bound(__x),
this); }
409 lower_bound(
const key_type& __x)
const
413 upper_bound(
const key_type& __x)
414 {
return iterator(_Base::upper_bound(__x),
this); }
419 upper_bound(
const key_type& __x)
const
423 equal_range(
const key_type& __x)
426 _Base::equal_range(__x);
434 equal_range(
const key_type& __x)
const
437 _Base::equal_range(__x);
443 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
446 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
457 template<
typename _Key,
typename _Compare,
typename _Allocator>
461 {
return __lhs._M_base() == __rhs._M_base(); }
463 template<
typename _Key,
typename _Compare,
typename _Allocator>
467 {
return __lhs._M_base() != __rhs._M_base(); }
469 template<
typename _Key,
typename _Compare,
typename _Allocator>
471 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
472 const multiset<_Key, _Compare, _Allocator>& __rhs)
473 {
return __lhs._M_base() < __rhs._M_base(); }
475 template<
typename _Key,
typename _Compare,
typename _Allocator>
477 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
478 const multiset<_Key, _Compare, _Allocator>& __rhs)
479 {
return __lhs._M_base() <= __rhs._M_base(); }
481 template<
typename _Key,
typename _Compare,
typename _Allocator>
483 operator>=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
484 const multiset<_Key, _Compare, _Allocator>& __rhs)
485 {
return __lhs._M_base() >= __rhs._M_base(); }
487 template<
typename _Key,
typename _Compare,
typename _Allocator>
489 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
490 const multiset<_Key, _Compare, _Allocator>& __rhs)
491 {
return __lhs._M_base() > __rhs._M_base(); }
493 template<
typename _Key,
typename _Compare,
typename _Allocator>
495 swap(multiset<_Key, _Compare, _Allocator>& __x,
496 multiset<_Key, _Compare, _Allocator>& __y)
497 {
return __x.swap(__y); }
Struct holding two objects of arbitrary type.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
size_t count() const noexcept
Returns the number of bits which are set.
void _M_swap(_Safe_sequence_base &__x)
void _M_invalidate_if(_Predicate __pred)
Uniform interface to C++98 and C++0x allocators.
Class std::multiset with safety/checking/debug instrumentation.
A standard container made up of elements, which can be retrieved in logarithmic time.
_T2 second
first is a copy of the first object
#define __glibcxx_check_insert(_Position)
_Iterator base() const noexcept
Return the underlying iterator.
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.
_T1 first
second_type is the second bound type
Base class for constructing a safe sequence type that tracks iterators that reference it...
constexpr size_t size() const noexcept
Returns the total number of bits.
#define __glibcxx_check_erase(_Position)
#define __glibcxx_check_erase_range(_First, _Last)