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)
108 multiset(initializer_list<value_type> __l,
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) { }
123 multiset(initializer_list<value_type> __l,
const allocator_type& __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();
158 this->_M_invalidate_all();
159 __x._M_invalidate_all();
164 operator=(initializer_list<value_type> __l)
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
181 {
return const_iterator(_Base::begin(),
this); }
184 end() _GLIBCXX_NOEXCEPT
185 {
return iterator(_Base::end(),
this); }
188 end()
const _GLIBCXX_NOEXCEPT
189 {
return const_iterator(_Base::end(),
this); }
192 rbegin() _GLIBCXX_NOEXCEPT
193 {
return reverse_iterator(end()); }
195 const_reverse_iterator
196 rbegin()
const _GLIBCXX_NOEXCEPT
197 {
return const_reverse_iterator(end()); }
200 rend() _GLIBCXX_NOEXCEPT
201 {
return reverse_iterator(begin()); }
203 const_reverse_iterator
204 rend()
const _GLIBCXX_NOEXCEPT
205 {
return const_reverse_iterator(begin()); }
207 #if __cplusplus >= 201103L
209 cbegin()
const noexcept
210 {
return const_iterator(_Base::begin(),
this); }
213 cend()
const noexcept
214 {
return const_iterator(_Base::end(),
this); }
216 const_reverse_iterator
217 crbegin()
const noexcept
218 {
return const_reverse_iterator(end()); }
220 const_reverse_iterator
221 crend()
const noexcept
222 {
return const_reverse_iterator(begin()); }
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>
241 emplace_hint(const_iterator __pos, _Args&&... __args)
244 return iterator(_Base::emplace_hint(__pos.
base(),
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); }
261 insert(const_iterator __position,
const value_type& __x)
264 return iterator(_Base::insert(__position.
base(), __x),
this);
267 #if __cplusplus >= 201103L
269 insert(const_iterator __position, value_type&& __x)
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
288 insert(initializer_list<value_type> __l)
289 { _Base::insert(__l); }
292 #if __cplusplus >= 201103L
294 erase(const_iterator __position)
298 return iterator(_Base::erase(__position.
base()),
this);
302 erase(iterator __position)
306 _Base::erase(__position.
base());
311 erase(
const key_type& __x)
314 _Base::equal_range(__x);
315 size_type __count = 0;
316 _Base_iterator __victim = __victims.
first;
317 while (__victim != __victims.
second)
320 _Base::erase(__victim++);
326 #if __cplusplus >= 201103L
328 erase(const_iterator __first, const_iterator __last)
333 for (_Base_const_iterator __victim = __first.
base();
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"));
342 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
346 erase(iterator __first, iterator __last)
351 for (_Base_iterator __victim = __first.
base();
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
398 {
return const_iterator(_Base::find(__x),
this); }
403 lower_bound(
const key_type& __x)
404 {
return iterator(_Base::lower_bound(__x),
this); }
409 lower_bound(
const key_type& __x)
const
410 {
return const_iterator(_Base::lower_bound(__x),
this); }
413 upper_bound(
const key_type& __x)
414 {
return iterator(_Base::upper_bound(__x),
this); }
419 upper_bound(
const key_type& __x)
const
420 {
return const_iterator(_Base::upper_bound(__x),
this); }
423 equal_range(
const key_type& __x)
426 _Base::equal_range(__x);
428 iterator(__res.
second,
this));
434 equal_range(
const key_type& __x)
const
437 _Base::equal_range(__x);
439 const_iterator(__res.
second,
this));
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); }
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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.
Uniform interface to C++98 and C++0x allocators.
#define __glibcxx_check_insert(_Position)
Base class for constructing a safe sequence type that tracks iterators that reference it...
void _M_invalidate_if(_Predicate __pred)
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
void _M_swap(_Safe_sequence_base &__x)
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
#define __glibcxx_check_erase(_Position)
Class std::multiset with safety/checking/debug instrumentation.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
A standard container made up of elements, which can be retrieved in logarithmic time.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
Struct holding two objects of arbitrary type.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
_Iterator base() const noexcept
Return the underlying iterator.
_T2 second
first is a copy of the first object
#define __glibcxx_check_erase_range(_First, _Last)