29 #ifndef _GLIBCXX_DEBUG_MULTIMAP_H
30 #define _GLIBCXX_DEBUG_MULTIMAP_H 1
41 template<
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
42 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
44 :
public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>,
46 _Compare, _Allocator> >
48 typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
50 typedef typename _Base::const_iterator _Base_const_iterator;
51 typedef typename _Base::iterator _Base_iterator;
55 typedef _Key key_type;
56 typedef _Tp mapped_type;
57 typedef std::pair<const _Key, _Tp> value_type;
58 typedef _Compare key_compare;
59 typedef _Allocator allocator_type;
60 typedef typename _Base::reference reference;
61 typedef typename _Base::const_reference const_reference;
66 multimap> const_iterator;
68 typedef typename _Base::size_type size_type;
69 typedef typename _Base::difference_type difference_type;
70 typedef typename _Base::pointer pointer;
71 typedef typename _Base::const_pointer const_pointer;
72 typedef std::reverse_iterator<iterator> reverse_iterator;
73 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
76 explicit multimap(
const _Compare& __comp = _Compare(),
77 const _Allocator& __a = _Allocator())
78 : _Base(__comp, __a) { }
80 template<
typename _InputIterator>
81 multimap(_InputIterator __first, _InputIterator __last,
82 const _Compare& __comp = _Compare(),
83 const _Allocator& __a = _Allocator())
89 multimap(
const multimap& __x)
92 multimap(
const _Base& __x)
95 #if __cplusplus >= 201103L
96 multimap(multimap&& __x)
97 noexcept(is_nothrow_copy_constructible<_Compare>::value)
98 : _Base(std::move(__x))
99 { this->_M_swap(__x); }
101 multimap(initializer_list<value_type> __l,
102 const _Compare& __c = _Compare(),
103 const allocator_type& __a = allocator_type())
104 : _Base(__l, __c, __a) { }
107 ~multimap() _GLIBCXX_NOEXCEPT { }
110 operator=(
const multimap& __x)
112 *
static_cast<_Base*
>(
this) = __x;
113 this->_M_invalidate_all();
117 #if __cplusplus >= 201103L
119 operator=(multimap&& __x)
130 operator=(initializer_list<value_type> __l)
138 using _Base::get_allocator;
142 begin() _GLIBCXX_NOEXCEPT
143 {
return iterator(_Base::begin(),
this); }
146 begin()
const _GLIBCXX_NOEXCEPT
147 {
return const_iterator(_Base::begin(),
this); }
150 end() _GLIBCXX_NOEXCEPT
151 {
return iterator(_Base::end(),
this); }
154 end()
const _GLIBCXX_NOEXCEPT
155 {
return const_iterator(_Base::end(),
this); }
158 rbegin() _GLIBCXX_NOEXCEPT
159 {
return reverse_iterator(end()); }
161 const_reverse_iterator
162 rbegin()
const _GLIBCXX_NOEXCEPT
163 {
return const_reverse_iterator(end()); }
166 rend() _GLIBCXX_NOEXCEPT
167 {
return reverse_iterator(begin()); }
169 const_reverse_iterator
170 rend()
const _GLIBCXX_NOEXCEPT
171 {
return const_reverse_iterator(begin()); }
173 #if __cplusplus >= 201103L
175 cbegin()
const noexcept
176 {
return const_iterator(_Base::begin(),
this); }
179 cend()
const noexcept
180 {
return const_iterator(_Base::end(),
this); }
182 const_reverse_iterator
183 crbegin()
const noexcept
184 {
return const_reverse_iterator(end()); }
186 const_reverse_iterator
187 crend()
const noexcept
188 {
return const_reverse_iterator(begin()); }
194 using _Base::max_size;
197 #if __cplusplus >= 201103L
198 template<
typename... _Args>
200 emplace(_Args&&... __args)
202 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
205 template<
typename... _Args>
207 emplace_hint(const_iterator __pos, _Args&&... __args)
210 return iterator(_Base::emplace_hint(__pos.base(),
211 std::forward<_Args>(__args)...),
217 insert(
const value_type& __x)
218 {
return iterator(_Base::insert(__x),
this); }
220 #if __cplusplus >= 201103L
221 template<
typename _Pair,
typename =
typename
222 std::enable_if<std::is_constructible<value_type,
223 _Pair&&>::value>::type>
226 {
return iterator(_Base::insert(std::forward<_Pair>(__x)),
this); }
229 #if __cplusplus >= 201103L
231 insert(std::initializer_list<value_type> __list)
232 { _Base::insert(__list); }
236 #if __cplusplus >= 201103L
237 insert(const_iterator __position,
const value_type& __x)
239 insert(iterator __position,
const value_type& __x)
243 return iterator(_Base::insert(__position.base(), __x),
this);
246 #if __cplusplus >= 201103L
247 template<
typename _Pair,
typename =
typename
248 std::enable_if<std::is_constructible<value_type,
249 _Pair&&>::value>::type>
251 insert(const_iterator __position, _Pair&& __x)
254 return iterator(_Base::insert(__position.base(),
255 std::forward<_Pair>(__x)),
this);
259 template<
typename _InputIterator>
261 insert(_InputIterator __first, _InputIterator __last)
268 #if __cplusplus >= 201103L
270 erase(const_iterator __position)
273 this->_M_invalidate_if(_Equal(__position.base()));
274 return iterator(_Base::erase(__position.base()),
this);
278 erase(iterator __position)
279 {
return erase(const_iterator(__position)); }
282 erase(iterator __position)
285 this->_M_invalidate_if(_Equal(__position.base()));
286 _Base::erase(__position.base());
291 erase(
const key_type& __x)
293 std::pair<_Base_iterator, _Base_iterator> __victims =
294 _Base::equal_range(__x);
295 size_type __count = 0;
296 _Base_iterator __victim = __victims.first;
297 while (__victim != __victims.second)
299 this->_M_invalidate_if(_Equal(__victim));
300 _Base::erase(__victim++);
306 #if __cplusplus >= 201103L
308 erase(const_iterator __first, const_iterator __last)
313 for (_Base_const_iterator __victim = __first.base();
314 __victim != __last.base(); ++__victim)
318 ._M_iterator(__first,
"first")
319 ._M_iterator(__last,
"last"));
320 this->_M_invalidate_if(_Equal(__victim));
322 return iterator(_Base::erase(__first.base(), __last.base()),
this);
326 erase(iterator __first, iterator __last)
331 for (_Base_iterator __victim = __first.base();
332 __victim != __last.base(); ++__victim)
336 ._M_iterator(__first,
"first")
337 ._M_iterator(__last,
"last"));
338 this->_M_invalidate_if(_Equal(__victim));
340 _Base::erase(__first.base(), __last.base());
352 clear() _GLIBCXX_NOEXCEPT
354 this->_M_invalidate_all();
359 using _Base::key_comp;
360 using _Base::value_comp;
364 find(
const key_type& __x)
365 {
return iterator(_Base::find(__x),
this); }
368 find(
const key_type& __x)
const
369 {
return const_iterator(_Base::find(__x),
this); }
374 lower_bound(
const key_type& __x)
375 {
return iterator(_Base::lower_bound(__x),
this); }
378 lower_bound(
const key_type& __x)
const
379 {
return const_iterator(_Base::lower_bound(__x),
this); }
382 upper_bound(
const key_type& __x)
383 {
return iterator(_Base::upper_bound(__x),
this); }
386 upper_bound(
const key_type& __x)
const
387 {
return const_iterator(_Base::upper_bound(__x),
this); }
389 std::pair<iterator,iterator>
390 equal_range(
const key_type& __x)
392 std::pair<_Base_iterator, _Base_iterator> __res =
393 _Base::equal_range(__x);
394 return std::make_pair(iterator(__res.first,
this),
395 iterator(__res.second,
this));
398 std::pair<const_iterator,const_iterator>
399 equal_range(
const key_type& __x)
const
401 std::pair<_Base_const_iterator, _Base_const_iterator> __res =
402 _Base::equal_range(__x);
403 return std::make_pair(const_iterator(__res.first,
this),
404 const_iterator(__res.second,
this));
408 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
411 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
418 this->_M_invalidate_if(_Not_equal(_Base::end()));
422 template<
typename _Key,
typename _Tp,
423 typename _Compare,
typename _Allocator>
425 operator==(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
426 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
427 {
return __lhs._M_base() == __rhs._M_base(); }
429 template<
typename _Key,
typename _Tp,
430 typename _Compare,
typename _Allocator>
432 operator!=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
433 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
434 {
return __lhs._M_base() != __rhs._M_base(); }
436 template<
typename _Key,
typename _Tp,
437 typename _Compare,
typename _Allocator>
439 operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
440 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
441 {
return __lhs._M_base() < __rhs._M_base(); }
443 template<
typename _Key,
typename _Tp,
444 typename _Compare,
typename _Allocator>
446 operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
447 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
448 {
return __lhs._M_base() <= __rhs._M_base(); }
450 template<
typename _Key,
typename _Tp,
451 typename _Compare,
typename _Allocator>
453 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
454 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
455 {
return __lhs._M_base() >= __rhs._M_base(); }
457 template<
typename _Key,
typename _Tp,
458 typename _Compare,
typename _Allocator>
460 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
461 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
462 {
return __lhs._M_base() > __rhs._M_base(); }
464 template<
typename _Key,
typename _Tp,
465 typename _Compare,
typename _Allocator>
467 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
468 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
469 { __lhs.swap(__rhs); }
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
namespace std _GLIBCXX_VISIBILITY(default)
Definition: multimap.h:36
Safe iterator wrapper.
Definition: formatter.h:46
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160