29 #ifndef _GLIBCXX_DEBUG_MULTIMAP_H
30 #define _GLIBCXX_DEBUG_MULTIMAP_H 1
36 namespace std _GLIBCXX_VISIBILITY(default)
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;
54 #if __cplusplus >= 201103L
60 typedef _Key key_type;
61 typedef _Tp mapped_type;
63 typedef _Compare key_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;
84 explicit multimap(
const _Compare& __comp,
85 const _Allocator& __a = _Allocator())
86 : _Base(__comp, __a) { }
88 template<
typename _InputIterator>
89 multimap(_InputIterator __first, _InputIterator __last,
90 const _Compare& __comp = _Compare(),
91 const _Allocator& __a = _Allocator())
103 #if __cplusplus >= 201103L
105 noexcept(is_nothrow_copy_constructible<_Compare>::value)
109 multimap(initializer_list<value_type> __l,
110 const _Compare& __c = _Compare(),
111 const allocator_type& __a = allocator_type())
112 : _Base(__l, __c, __a) { }
119 : _Base(__m, __a) { }
122 : _Base(
std::move(__m._M_base()), __a) { }
124 multimap(initializer_list<value_type> __l,
const allocator_type& __a)
128 template<
typename _InputIterator>
129 multimap(_InputIterator __first, _InputIterator __last,
130 const allocator_type& __a)
143 this->_M_invalidate_all();
147 #if __cplusplus >= 201103L
150 noexcept(_Alloc_traits::_S_nothrow_move())
152 __glibcxx_check_self_move_assign(__x);
153 bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign()
154 || __x.get_allocator() == this->get_allocator();
159 this->_M_invalidate_all();
160 __x._M_invalidate_all();
165 operator=(initializer_list<value_type> __l)
168 this->_M_invalidate_all();
173 using _Base::get_allocator;
177 begin() _GLIBCXX_NOEXCEPT
178 {
return iterator(_Base::begin(),
this); }
181 begin()
const _GLIBCXX_NOEXCEPT
182 {
return const_iterator(_Base::begin(),
this); }
185 end() _GLIBCXX_NOEXCEPT
186 {
return iterator(_Base::end(),
this); }
189 end()
const _GLIBCXX_NOEXCEPT
190 {
return const_iterator(_Base::end(),
this); }
193 rbegin() _GLIBCXX_NOEXCEPT
194 {
return reverse_iterator(end()); }
196 const_reverse_iterator
197 rbegin()
const _GLIBCXX_NOEXCEPT
198 {
return const_reverse_iterator(end()); }
201 rend() _GLIBCXX_NOEXCEPT
202 {
return reverse_iterator(begin()); }
204 const_reverse_iterator
205 rend()
const _GLIBCXX_NOEXCEPT
206 {
return const_reverse_iterator(begin()); }
208 #if __cplusplus >= 201103L
210 cbegin()
const noexcept
211 {
return const_iterator(_Base::begin(),
this); }
214 cend()
const noexcept
215 {
return const_iterator(_Base::end(),
this); }
217 const_reverse_iterator
218 crbegin()
const noexcept
219 {
return const_reverse_iterator(end()); }
221 const_reverse_iterator
222 crend()
const noexcept
223 {
return const_reverse_iterator(begin()); }
229 using _Base::max_size;
232 #if __cplusplus >= 201103L
233 template<
typename... _Args>
235 emplace(_Args&&... __args)
237 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
240 template<
typename... _Args>
242 emplace_hint(const_iterator __pos, _Args&&... __args)
245 return iterator(_Base::emplace_hint(__pos.
base(),
246 std::forward<_Args>(__args)...),
252 insert(
const value_type& __x)
253 {
return iterator(_Base::insert(__x),
this); }
255 #if __cplusplus >= 201103L
256 template<
typename _Pair,
typename =
typename
257 std::enable_if<std::is_constructible<value_type,
258 _Pair&&>::value>::type>
261 {
return iterator(_Base::insert(std::forward<_Pair>(__x)),
this); }
264 #if __cplusplus >= 201103L
266 insert(std::initializer_list<value_type> __list)
267 { _Base::insert(__list); }
271 #if __cplusplus >= 201103L
272 insert(const_iterator __position,
const value_type& __x)
274 insert(iterator __position,
const value_type& __x)
278 return iterator(_Base::insert(__position.
base(), __x),
this);
281 #if __cplusplus >= 201103L
282 template<
typename _Pair,
typename =
typename
283 std::enable_if<std::is_constructible<value_type,
284 _Pair&&>::value>::type>
286 insert(const_iterator __position, _Pair&& __x)
289 return iterator(_Base::insert(__position.
base(),
290 std::forward<_Pair>(__x)),
this);
294 template<
typename _InputIterator>
296 insert(_InputIterator __first, _InputIterator __last)
298 __glibcxx_check_valid_range(__first, __last);
303 #if __cplusplus >= 201103L
305 erase(const_iterator __position)
309 return iterator(_Base::erase(__position.
base()),
this);
313 erase(iterator __position)
314 {
return erase(const_iterator(__position)); }
317 erase(iterator __position)
321 _Base::erase(__position.
base());
326 erase(
const key_type& __x)
329 _Base::equal_range(__x);
330 size_type __count = 0;
331 _Base_iterator __victim = __victims.
first;
332 while (__victim != __victims.
second)
335 _Base::erase(__victim++);
341 #if __cplusplus >= 201103L
343 erase(const_iterator __first, const_iterator __last)
348 for (_Base_const_iterator __victim = __first.
base();
349 __victim != __last.
base(); ++__victim)
351 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
352 _M_message(__gnu_debug::__msg_valid_range)
353 ._M_iterator(__first,
"first")
354 ._M_iterator(__last,
"last"));
357 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
361 erase(iterator __first, iterator __last)
366 for (_Base_iterator __victim = __first.
base();
367 __victim != __last.
base(); ++__victim)
369 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
370 _M_message(__gnu_debug::__msg_valid_range)
371 ._M_iterator(__first,
"first")
372 ._M_iterator(__last,
"last"));
375 _Base::erase(__first.
base(), __last.
base());
381 #if __cplusplus >= 201103L
382 noexcept(_Alloc_traits::_S_nothrow_swap())
385 #if __cplusplus >= 201103L
386 if (!_Alloc_traits::_S_propagate_on_swap())
387 __glibcxx_check_equal_allocs(__x);
394 clear() _GLIBCXX_NOEXCEPT
396 this->_M_invalidate_all();
401 using _Base::key_comp;
402 using _Base::value_comp;
406 find(
const key_type& __x)
407 {
return iterator(_Base::find(__x),
this); }
410 find(
const key_type& __x)
const
411 {
return const_iterator(_Base::find(__x),
this); }
416 lower_bound(
const key_type& __x)
417 {
return iterator(_Base::lower_bound(__x),
this); }
420 lower_bound(
const key_type& __x)
const
421 {
return const_iterator(_Base::lower_bound(__x),
this); }
424 upper_bound(
const key_type& __x)
425 {
return iterator(_Base::upper_bound(__x),
this); }
428 upper_bound(
const key_type& __x)
const
429 {
return const_iterator(_Base::upper_bound(__x),
this); }
432 equal_range(
const key_type& __x)
435 _Base::equal_range(__x);
437 iterator(__res.
second,
this));
441 equal_range(
const key_type& __x)
const
444 _Base::equal_range(__x);
446 const_iterator(__res.
second,
this));
450 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
453 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
464 template<
typename _Key,
typename _Tp,
465 typename _Compare,
typename _Allocator>
469 {
return __lhs._M_base() == __rhs._M_base(); }
471 template<
typename _Key,
typename _Tp,
472 typename _Compare,
typename _Allocator>
476 {
return __lhs._M_base() != __rhs._M_base(); }
478 template<
typename _Key,
typename _Tp,
479 typename _Compare,
typename _Allocator>
481 operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
482 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
483 {
return __lhs._M_base() < __rhs._M_base(); }
485 template<
typename _Key,
typename _Tp,
486 typename _Compare,
typename _Allocator>
488 operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
489 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
490 {
return __lhs._M_base() <= __rhs._M_base(); }
492 template<
typename _Key,
typename _Tp,
493 typename _Compare,
typename _Allocator>
495 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
496 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
497 {
return __lhs._M_base() >= __rhs._M_base(); }
499 template<
typename _Key,
typename _Tp,
500 typename _Compare,
typename _Allocator>
502 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
503 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
504 {
return __lhs._M_base() > __rhs._M_base(); }
506 template<
typename _Key,
typename _Tp,
507 typename _Compare,
typename _Allocator>
509 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
510 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
511 { __lhs.swap(__rhs); }
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)
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 (key,value) pairs, which can be retrieved based on a key...
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)
Class std::multimap with safety/checking/debug instrumentation.