Class std::multiset with safety/checking/debug instrumentation.
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;
49 typedef typename _Base::const_iterator _Base_const_iterator;
50 typedef typename _Base::iterator _Base_iterator;
54 typedef _Key key_type;
55 typedef _Key value_type;
56 typedef _Compare key_compare;
57 typedef _Compare value_compare;
58 typedef _Allocator allocator_type;
59 typedef typename _Base::reference reference;
60 typedef typename _Base::const_reference const_reference;
65 multiset> const_iterator;
67 typedef typename _Base::size_type size_type;
68 typedef typename _Base::difference_type difference_type;
69 typedef typename _Base::pointer pointer;
70 typedef typename _Base::const_pointer const_pointer;
71 typedef std::reverse_iterator<iterator> reverse_iterator;
72 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
75 explicit multiset(
const _Compare& __comp = _Compare(),
76 const _Allocator& __a = _Allocator())
77 : _Base(__comp, __a) { }
79 template<
typename _InputIterator>
80 multiset(_InputIterator __first, _InputIterator __last,
81 const _Compare& __comp = _Compare(),
82 const _Allocator& __a = _Allocator())
85 __gnu_debug::
__base(__last),
88 multiset(
const multiset& __x)
91 multiset(
const _Base& __x)
94 #if __cplusplus >= 201103L
95 multiset(multiset&& __x)
96 noexcept(is_nothrow_copy_constructible<_Compare>::value)
97 : _Base(std::move(__x))
98 { this->_M_swap(__x); }
100 multiset(initializer_list<value_type> __l,
101 const _Compare& __comp = _Compare(),
102 const allocator_type& __a = allocator_type())
103 : _Base(__l, __comp, __a) { }
106 ~multiset() _GLIBCXX_NOEXCEPT { }
109 operator=(
const multiset& __x)
111 *
static_cast<_Base*
>(
this) = __x;
112 this->_M_invalidate_all();
116 #if __cplusplus >= 201103L
118 operator=(multiset&& __x)
129 operator=(initializer_list<value_type> __l)
137 using _Base::get_allocator;
141 begin() _GLIBCXX_NOEXCEPT
142 {
return iterator(_Base::begin(),
this); }
145 begin() const _GLIBCXX_NOEXCEPT
146 {
return const_iterator(_Base::begin(),
this); }
149 end() _GLIBCXX_NOEXCEPT
150 {
return iterator(_Base::end(),
this); }
153 end() const _GLIBCXX_NOEXCEPT
154 {
return const_iterator(_Base::end(),
this); }
157 rbegin() _GLIBCXX_NOEXCEPT
158 {
return reverse_iterator(end()); }
160 const_reverse_iterator
161 rbegin() const _GLIBCXX_NOEXCEPT
162 {
return const_reverse_iterator(end()); }
165 rend() _GLIBCXX_NOEXCEPT
166 {
return reverse_iterator(begin()); }
168 const_reverse_iterator
169 rend() const _GLIBCXX_NOEXCEPT
170 {
return const_reverse_iterator(begin()); }
172 #if __cplusplus >= 201103L
174 cbegin() const noexcept
175 {
return const_iterator(_Base::begin(),
this); }
178 cend() const noexcept
179 {
return const_iterator(_Base::end(),
this); }
181 const_reverse_iterator
182 crbegin() const noexcept
183 {
return const_reverse_iterator(end()); }
185 const_reverse_iterator
186 crend() const noexcept
187 {
return const_reverse_iterator(begin()); }
193 using _Base::max_size;
196 #if __cplusplus >= 201103L
197 template<
typename... _Args>
199 emplace(_Args&&... __args)
201 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
204 template<
typename... _Args>
206 emplace_hint(const_iterator __pos, _Args&&... __args)
209 return iterator(_Base::emplace_hint(__pos.base(),
210 std::forward<_Args>(__args)...),
216 insert(
const value_type& __x)
217 {
return iterator(_Base::insert(__x),
this); }
219 #if __cplusplus >= 201103L
221 insert(value_type&& __x)
222 {
return iterator(_Base::insert(std::move(__x)),
this); }
226 insert(const_iterator __position,
const value_type& __x)
229 return iterator(_Base::insert(__position.base(), __x),
this);
232 #if __cplusplus >= 201103L
234 insert(const_iterator __position, value_type&& __x)
237 return iterator(_Base::insert(__position.base(), std::move(__x)),
242 template<
typename _InputIterator>
244 insert(_InputIterator __first, _InputIterator __last)
251 #if __cplusplus >= 201103L
253 insert(initializer_list<value_type> __l)
254 { _Base::insert(__l); }
257 #if __cplusplus >= 201103L
259 erase(const_iterator __position)
262 this->_M_invalidate_if(_Equal(__position.base()));
263 return iterator(_Base::erase(__position.base()),
this);
267 erase(iterator __position)
270 this->_M_invalidate_if(_Equal(__position.base()));
271 _Base::erase(__position.base());
276 erase(
const key_type& __x)
278 std::pair<_Base_iterator, _Base_iterator> __victims =
279 _Base::equal_range(__x);
280 size_type __count = 0;
281 _Base_iterator __victim = __victims.first;
282 while (__victim != __victims.second)
284 this->_M_invalidate_if(_Equal(__victim));
285 _Base::erase(__victim++);
291 #if __cplusplus >= 201103L
293 erase(const_iterator __first, const_iterator __last)
298 for (_Base_const_iterator __victim = __first.base();
299 __victim != __last.base(); ++__victim)
303 ._M_iterator(__first,
"first")
304 ._M_iterator(__last,
"last"));
305 this->_M_invalidate_if(_Equal(__victim));
307 return iterator(_Base::erase(__first.base(), __last.base()),
this);
311 erase(iterator __first, iterator __last)
316 for (_Base_iterator __victim = __first.base();
317 __victim != __last.base(); ++__victim)
321 ._M_iterator(__first,
"first")
322 ._M_iterator(__last,
"last"));
323 this->_M_invalidate_if(_Equal(__victim));
325 _Base::erase(__first.base(), __last.base());
337 clear() _GLIBCXX_NOEXCEPT
339 this->_M_invalidate_all();
344 using _Base::key_comp;
345 using _Base::value_comp;
349 find(
const key_type& __x)
350 {
return iterator(_Base::find(__x),
this); }
355 find(
const key_type& __x)
const
356 {
return const_iterator(_Base::find(__x),
this); }
361 lower_bound(
const key_type& __x)
362 {
return iterator(_Base::lower_bound(__x),
this); }
367 lower_bound(
const key_type& __x)
const
368 {
return const_iterator(_Base::lower_bound(__x),
this); }
371 upper_bound(
const key_type& __x)
372 {
return iterator(_Base::upper_bound(__x),
this); }
377 upper_bound(
const key_type& __x)
const
378 {
return const_iterator(_Base::upper_bound(__x),
this); }
380 std::pair<iterator,iterator>
381 equal_range(
const key_type& __x)
383 std::pair<_Base_iterator, _Base_iterator> __res =
384 _Base::equal_range(__x);
385 return std::make_pair(iterator(__res.first,
this),
386 iterator(__res.second,
this));
391 std::pair<const_iterator,const_iterator>
392 equal_range(
const key_type& __x)
const
394 std::pair<_Base_const_iterator, _Base_const_iterator> __res =
395 _Base::equal_range(__x);
396 return std::make_pair(const_iterator(__res.first,
this),
397 const_iterator(__res.second,
this));
401 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
404 _M_base() const _GLIBCXX_NOEXCEPT {
return *
this; }
411 this->_M_invalidate_if(_Not_equal(_Base::end()));
415 template<
typename _Key,
typename _Compare,
typename _Allocator>
417 operator==(
const multiset<_Key, _Compare, _Allocator>& __lhs,
418 const multiset<_Key, _Compare, _Allocator>& __rhs)
419 {
return __lhs._M_base() == __rhs._M_base(); }
421 template<
typename _Key,
typename _Compare,
typename _Allocator>
423 operator!=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
424 const multiset<_Key, _Compare, _Allocator>& __rhs)
425 {
return __lhs._M_base() != __rhs._M_base(); }
427 template<
typename _Key,
typename _Compare,
typename _Allocator>
429 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
430 const multiset<_Key, _Compare, _Allocator>& __rhs)
431 {
return __lhs._M_base() < __rhs._M_base(); }
433 template<
typename _Key,
typename _Compare,
typename _Allocator>
435 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
436 const multiset<_Key, _Compare, _Allocator>& __rhs)
437 {
return __lhs._M_base() <= __rhs._M_base(); }
439 template<
typename _Key,
typename _Compare,
typename _Allocator>
441 operator>=(
const multiset<_Key, _Compare, _Allocator>& __lhs,
442 const multiset<_Key, _Compare, _Allocator>& __rhs)
443 {
return __lhs._M_base() >= __rhs._M_base(); }
445 template<
typename _Key,
typename _Compare,
typename _Allocator>
447 operator>(
const multiset<_Key, _Compare, _Allocator>& __lhs,
448 const multiset<_Key, _Compare, _Allocator>& __rhs)
449 {
return __lhs._M_base() > __rhs._M_base(); }
451 template<
typename _Key,
typename _Compare,
typename _Allocator>
453 swap(multiset<_Key, _Compare, _Allocator>& __x,
454 multiset<_Key, _Compare, _Allocator>& __y)
455 {
return __x.swap(__y); }
bool operator>=(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:644
Definition: safe_sequence.h:62
Definition: safe_sequence.h:47
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Definition: functions.h:446
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
#define __glibcxx_check_erase(_Position)
Definition: macros.h:135
#define __glibcxx_check_insert(_Position)
Definition: macros.h:73
#define __glibcxx_check_valid_range(_First, _Last)
Definition: macros.h:53
_InputIterator __check_valid_range(const _InputIterator &__first, const _InputIterator &__last __attribute__((__unused__)))
Definition: functions.h:157
bool operator>(const _Safe_iterator< _IteratorL, _Sequence > &__lhs, const _Safe_iterator< _IteratorR, _Sequence > &__rhs)
Definition: safe_iterator.h:612
#define __glibcxx_check_self_move_assign(_Other)
Definition: macros.h:328
Definition: formatter.h:57
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
Base class for constructing a safe sequence type that tracks iterators that reference it...
Definition: formatter.h:52
#define __glibcxx_check_erase_range(_First, _Last)
Definition: macros.h:163
#define _GLIBCXX_DEBUG_VERIFY(_Condition, _ErrorMessage)
Definition: macros.h:49
Safe iterator wrapper.
Definition: formatter.h:46
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160