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)
117 : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
119 __gnu_debug::__base(__last), __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())
132 : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first,
134 __gnu_debug::__base(__last),
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)
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 > 201402L 291 using node_type =
typename _Base::node_type;
294 extract(const_iterator __position)
298 return _Base::extract(__position.
base());
302 extract(
const key_type& __key)
304 const auto __position = find(__key);
305 if (__position != end())
306 return extract(__position);
311 insert(node_type&& __nh)
312 {
return iterator(_Base::insert(std::move(__nh)),
this); }
315 insert(const_iterator __hint, node_type&& __nh)
318 return iterator(_Base::insert(__hint.
base(), std::move(__nh)),
this);
324 #if __cplusplus >= 201103L 326 erase(const_iterator __position)
330 return iterator(_Base::erase(__position.
base()),
this);
334 erase(iterator __position)
338 _Base::erase(__position.
base());
343 erase(
const key_type& __x)
346 _Base::equal_range(__x);
347 size_type __count = 0;
348 _Base_iterator __victim = __victims.
first;
349 while (__victim != __victims.
second)
352 _Base::erase(__victim++);
358 #if __cplusplus >= 201103L 360 erase(const_iterator __first, const_iterator __last)
365 for (_Base_const_iterator __victim = __first.
base();
366 __victim != __last.
base(); ++__victim)
368 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
369 _M_message(__gnu_debug::__msg_valid_range)
370 ._M_iterator(__first,
"first")
371 ._M_iterator(__last,
"last"));
374 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
378 erase(iterator __first, iterator __last)
383 for (_Base_iterator __victim = __first.
base();
384 __victim != __last.
base(); ++__victim)
386 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
387 _M_message(__gnu_debug::__msg_valid_range)
388 ._M_iterator(__first,
"first")
389 ._M_iterator(__last,
"last"));
392 _Base::erase(__first.
base(), __last.
base());
398 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
405 clear() _GLIBCXX_NOEXCEPT
407 this->_M_invalidate_all();
412 using _Base::key_comp;
413 using _Base::value_comp;
417 find(
const key_type& __x)
418 {
return iterator(_Base::find(__x),
this); }
423 find(
const key_type& __x)
const 424 {
return const_iterator(_Base::find(__x),
this); }
426 #if __cplusplus > 201103L 427 template<
typename _Kt,
429 typename __has_is_transparent<_Compare, _Kt>::type>
432 {
return { _Base::find(__x),
this }; }
434 template<
typename _Kt,
436 typename __has_is_transparent<_Compare, _Kt>::type>
438 find(
const _Kt& __x)
const 439 {
return { _Base::find(__x),
this }; }
445 lower_bound(
const key_type& __x)
446 {
return iterator(_Base::lower_bound(__x),
this); }
451 lower_bound(
const key_type& __x)
const 452 {
return const_iterator(_Base::lower_bound(__x),
this); }
454 #if __cplusplus > 201103L 455 template<
typename _Kt,
457 typename __has_is_transparent<_Compare, _Kt>::type>
459 lower_bound(
const _Kt& __x)
460 {
return { _Base::lower_bound(__x),
this }; }
462 template<
typename _Kt,
464 typename __has_is_transparent<_Compare, _Kt>::type>
466 lower_bound(
const _Kt& __x)
const 467 {
return { _Base::lower_bound(__x),
this }; }
471 upper_bound(
const key_type& __x)
472 {
return iterator(_Base::upper_bound(__x),
this); }
477 upper_bound(
const key_type& __x)
const 478 {
return const_iterator(_Base::upper_bound(__x),
this); }
480 #if __cplusplus > 201103L 481 template<
typename _Kt,
483 typename __has_is_transparent<_Compare, _Kt>::type>
485 upper_bound(
const _Kt& __x)
486 {
return { _Base::upper_bound(__x),
this }; }
488 template<
typename _Kt,
490 typename __has_is_transparent<_Compare, _Kt>::type>
492 upper_bound(
const _Kt& __x)
const 493 {
return { _Base::upper_bound(__x),
this }; }
497 equal_range(
const key_type& __x)
500 _Base::equal_range(__x);
502 iterator(__res.
second,
this));
508 equal_range(
const key_type& __x)
const 511 _Base::equal_range(__x);
513 const_iterator(__res.
second,
this));
516 #if __cplusplus > 201103L 517 template<
typename _Kt,
519 typename __has_is_transparent<_Compare, _Kt>::type>
521 equal_range(
const _Kt& __x)
523 auto __res = _Base::equal_range(__x);
524 return { { __res.first,
this }, { __res.second,
this } };
527 template<
typename _Kt,
529 typename __has_is_transparent<_Compare, _Kt>::type>
531 equal_range(
const _Kt& __x)
const 533 auto __res = _Base::equal_range(__x);
534 return { { __res.first,
this }, { __res.second,
this } };
539 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
542 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
545 template<
typename _Key,
typename _Compare,
typename _Allocator>
549 {
return __lhs._M_base() == __rhs._M_base(); }
551 template<
typename _Key,
typename _Compare,
typename _Allocator>
555 {
return __lhs._M_base() != __rhs._M_base(); }
557 template<
typename _Key,
typename _Compare,
typename _Allocator>
559 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
561 {
return __lhs._M_base() < __rhs._M_base(); }
563 template<
typename _Key,
typename _Compare,
typename _Allocator>
565 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
567 {
return __lhs._M_base() <= __rhs._M_base(); }
569 template<
typename _Key,
typename _Compare,
typename _Allocator>
573 {
return __lhs._M_base() >= __rhs._M_base(); }
575 template<
typename _Key,
typename _Compare,
typename _Allocator>
579 {
return __lhs._M_base() > __rhs._M_base(); }
581 template<
typename _Key,
typename _Compare,
typename _Allocator>
585 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
586 {
return __x.swap(__y); }
_T2 second
first is a copy of the first object
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_erase_range(_First, _Last)
Safe class dealing with some allocator dependent operations.
#define __glibcxx_check_erase(_Position)
_Iterator & base() noexcept
Return the underlying iterator.
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
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_insert(_Position)
Struct holding two objects of arbitrary type.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
Class std::multiset with safety/checking/debug instrumentation.