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 83 multiset() : _Base() { }
85 multiset(
const multiset& __x)
91 multiset(
const multiset&) =
default;
92 multiset(multiset&&) =
default;
95 const _Compare& __comp = _Compare(),
96 const allocator_type& __a = allocator_type())
97 : _Base(__l, __comp, __a) { }
100 multiset(
const allocator_type& __a)
103 multiset(
const multiset& __m,
const allocator_type& __a)
104 : _Base(__m, __a) { }
106 multiset(multiset&& __m,
const allocator_type& __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)
121 ~multiset() =
default;
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())
137 multiset(
const _Base& __x)
140 #if __cplusplus < 201103L 142 operator=(
const multiset& __x)
144 this->_M_safe() = __x;
150 operator=(
const multiset&) =
default;
153 operator=(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
173 {
return const_iterator(_Base::begin(),
this); }
176 end() _GLIBCXX_NOEXCEPT
177 {
return iterator(_Base::end(),
this); }
180 end()
const _GLIBCXX_NOEXCEPT
181 {
return const_iterator(_Base::end(),
this); }
184 rbegin() _GLIBCXX_NOEXCEPT
185 {
return reverse_iterator(end()); }
187 const_reverse_iterator
188 rbegin()
const _GLIBCXX_NOEXCEPT
189 {
return const_reverse_iterator(end()); }
192 rend() _GLIBCXX_NOEXCEPT
193 {
return reverse_iterator(begin()); }
195 const_reverse_iterator
196 rend()
const _GLIBCXX_NOEXCEPT
197 {
return const_reverse_iterator(begin()); }
199 #if __cplusplus >= 201103L 201 cbegin()
const noexcept
202 {
return const_iterator(_Base::begin(),
this); }
205 cend()
const noexcept
206 {
return const_iterator(_Base::end(),
this); }
208 const_reverse_iterator
209 crbegin()
const noexcept
210 {
return const_reverse_iterator(end()); }
212 const_reverse_iterator
213 crend()
const noexcept
214 {
return const_reverse_iterator(begin()); }
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>
234 emplace_hint(const_iterator __pos, _Args&&... __args)
237 return iterator(_Base::emplace_hint(__pos.
base(),
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); }
254 insert(const_iterator __position,
const value_type& __x)
257 return iterator(_Base::insert(__position.
base(), __x),
this);
260 #if __cplusplus >= 201103L 262 insert(const_iterator __position, value_type&& __x)
265 return iterator(_Base::insert(__position.
base(), std::move(__x)),
270 template<
typename _InputIterator>
272 insert(_InputIterator __first, _InputIterator __last)
274 __glibcxx_check_valid_range(__first, __last);
279 #if __cplusplus >= 201103L 282 { _Base::insert(__l); }
285 #if __cplusplus >= 201103L 287 erase(const_iterator __position)
291 return iterator(_Base::erase(__position.
base()),
this);
295 erase(iterator __position)
299 _Base::erase(__position.
base());
304 erase(
const key_type& __x)
307 _Base::equal_range(__x);
308 size_type __count = 0;
309 _Base_iterator __victim = __victims.
first;
310 while (__victim != __victims.
second)
313 _Base::erase(__victim++);
319 #if __cplusplus >= 201103L 321 erase(const_iterator __first, const_iterator __last)
326 for (_Base_const_iterator __victim = __first.
base();
327 __victim != __last.
base(); ++__victim)
329 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
330 _M_message(__gnu_debug::__msg_valid_range)
331 ._M_iterator(__first,
"first")
332 ._M_iterator(__last,
"last"));
335 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
339 erase(iterator __first, iterator __last)
344 for (_Base_iterator __victim = __first.
base();
345 __victim != __last.
base(); ++__victim)
347 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
348 _M_message(__gnu_debug::__msg_valid_range)
349 ._M_iterator(__first,
"first")
350 ._M_iterator(__last,
"last"));
353 _Base::erase(__first.
base(), __last.
base());
359 #if __cplusplus >= 201103L 360 noexcept( noexcept(declval<_Base>().swap(__x)) )
368 clear() _GLIBCXX_NOEXCEPT
370 this->_M_invalidate_all();
375 using _Base::key_comp;
376 using _Base::value_comp;
380 find(
const key_type& __x)
381 {
return iterator(_Base::find(__x),
this); }
386 find(
const key_type& __x)
const 387 {
return const_iterator(_Base::find(__x),
this); }
392 lower_bound(
const key_type& __x)
393 {
return iterator(_Base::lower_bound(__x),
this); }
398 lower_bound(
const key_type& __x)
const 399 {
return const_iterator(_Base::lower_bound(__x),
this); }
402 upper_bound(
const key_type& __x)
403 {
return iterator(_Base::upper_bound(__x),
this); }
408 upper_bound(
const key_type& __x)
const 409 {
return const_iterator(_Base::upper_bound(__x),
this); }
412 equal_range(
const key_type& __x)
415 _Base::equal_range(__x);
417 iterator(__res.
second,
this));
423 equal_range(
const key_type& __x)
const 426 _Base::equal_range(__x);
428 const_iterator(__res.
second,
this));
432 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
435 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
438 template<
typename _Key,
typename _Compare,
typename _Allocator>
442 {
return __lhs._M_base() == __rhs._M_base(); }
444 template<
typename _Key,
typename _Compare,
typename _Allocator>
448 {
return __lhs._M_base() != __rhs._M_base(); }
450 template<
typename _Key,
typename _Compare,
typename _Allocator>
452 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
454 {
return __lhs._M_base() < __rhs._M_base(); }
456 template<
typename _Key,
typename _Compare,
typename _Allocator>
458 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
460 {
return __lhs._M_base() <= __rhs._M_base(); }
462 template<
typename _Key,
typename _Compare,
typename _Allocator>
466 {
return __lhs._M_base() >= __rhs._M_base(); }
468 template<
typename _Key,
typename _Compare,
typename _Allocator>
472 {
return __lhs._M_base() > __rhs._M_base(); }
474 template<
typename _Key,
typename _Compare,
typename _Allocator>
478 {
return __x.swap(__y); }
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
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.
_Iterator & base() noexcept
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
Safe class dealing with some allocator dependent operations.
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
_T2 second
first is a copy of the first object
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Struct holding two objects of arbitrary type.
Class std::multiset with safety/checking/debug instrumentation.
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
#define __glibcxx_check_insert(_Position)