30 #ifndef _GLIBCXX_DEBUG_MULTIMAP_H
31 #define _GLIBCXX_DEBUG_MULTIMAP_H 1
37 namespace std _GLIBCXX_VISIBILITY(default)
42 template<
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
43 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
45 :
public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>,
47 _Compare, _Allocator> >
49 typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>
_Base;
56 typedef _Key key_type;
57 typedef _Tp mapped_type;
59 typedef _Compare key_compare;
60 typedef _Allocator allocator_type;
61 typedef typename _Base::reference reference;
62 typedef typename _Base::const_reference const_reference;
69 typedef typename _Base::size_type size_type;
70 typedef typename _Base::difference_type difference_type;
71 typedef typename _Base::pointer pointer;
72 typedef typename _Base::const_pointer const_pointer;
77 explicit multimap(
const _Compare& __comp = _Compare(),
78 const _Allocator& __a = _Allocator())
79 : _Base(__comp, __a) { }
81 template<
typename _InputIterator>
82 multimap(_InputIterator __first, _InputIterator __last,
83 const _Compare& __comp = _Compare(),
84 const _Allocator& __a = _Allocator())
96 #ifdef __GXX_EXPERIMENTAL_CXX0X__
98 noexcept(is_nothrow_copy_constructible<_Compare>::value)
102 multimap(initializer_list<value_type> __l,
103 const _Compare& __c = _Compare(),
104 const allocator_type& __a = allocator_type())
105 : _Base(__l, __c, __a) { }
113 *
static_cast<_Base*
>(
this) = __x;
114 this->_M_invalidate_all();
118 #ifdef __GXX_EXPERIMENTAL_CXX0X__
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 #ifdef __GXX_EXPERIMENTAL_CXX0X__
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;
198 insert(
const value_type& __x)
199 {
return iterator(_Base::insert(__x),
this); }
201 #ifdef __GXX_EXPERIMENTAL_CXX0X__
202 template<
typename _Pair,
typename =
typename
203 std::enable_if<std::is_constructible<value_type,
204 _Pair&&>::value>::type>
207 {
return iterator(_Base::insert(std::forward<_Pair>(__x)),
this); }
210 #ifdef __GXX_EXPERIMENTAL_CXX0X__
212 insert(std::initializer_list<value_type> __list)
213 { _Base::insert(__list); }
217 #ifdef __GXX_EXPERIMENTAL_CXX0X__
218 insert(const_iterator __position,
const value_type& __x)
220 insert(iterator __position,
const value_type& __x)
224 return iterator(_Base::insert(__position.
base(), __x),
this);
227 #ifdef __GXX_EXPERIMENTAL_CXX0X__
228 template<
typename _Pair,
typename =
typename
229 std::enable_if<std::is_constructible<value_type,
230 _Pair&&>::value>::type>
232 insert(const_iterator __position, _Pair&& __x)
235 return iterator(_Base::insert(__position.
base(),
236 std::forward<_Pair>(__x)),
this);
240 template<
typename _InputIterator>
242 insert(_InputIterator __first, _InputIterator __last)
244 __glibcxx_check_valid_range(__first, __last);
249 #ifdef __GXX_EXPERIMENTAL_CXX0X__
251 erase(const_iterator __position)
255 return iterator(_Base::erase(__position.
base()),
this);
259 erase(iterator __position)
260 {
return erase(const_iterator(__position)); }
263 erase(iterator __position)
267 _Base::erase(__position.
base());
272 erase(
const key_type& __x)
275 _Base::equal_range(__x);
276 size_type __count = 0;
277 _Base_iterator __victim = __victims.
first;
278 while (__victim != __victims.
second)
281 _Base::erase(__victim++);
287 #ifdef __GXX_EXPERIMENTAL_CXX0X__
289 erase(const_iterator __first, const_iterator __last)
294 for (_Base_const_iterator __victim = __first.
base();
295 __victim != __last.
base(); ++__victim)
297 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
298 _M_message(__gnu_debug::__msg_valid_range)
299 ._M_iterator(__first,
"first")
300 ._M_iterator(__last,
"last"));
303 return iterator(_Base::erase(__first.
base(), __last.
base()),
this);
307 erase(iterator __first, iterator __last)
312 for (_Base_iterator __victim = __first.
base();
313 __victim != __last.
base(); ++__victim)
315 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
316 _M_message(__gnu_debug::__msg_valid_range)
317 ._M_iterator(__first,
"first")
318 ._M_iterator(__last,
"last"));
321 _Base::erase(__first.
base(), __last.
base());
333 clear() _GLIBCXX_NOEXCEPT
335 this->_M_invalidate_all();
340 using _Base::key_comp;
341 using _Base::value_comp;
345 find(
const key_type& __x)
346 {
return iterator(_Base::find(__x),
this); }
349 find(
const key_type& __x)
const
350 {
return const_iterator(_Base::find(__x),
this); }
355 lower_bound(
const key_type& __x)
356 {
return iterator(_Base::lower_bound(__x),
this); }
359 lower_bound(
const key_type& __x)
const
360 {
return const_iterator(_Base::lower_bound(__x),
this); }
363 upper_bound(
const key_type& __x)
364 {
return iterator(_Base::upper_bound(__x),
this); }
367 upper_bound(
const key_type& __x)
const
368 {
return const_iterator(_Base::upper_bound(__x),
this); }
371 equal_range(
const key_type& __x)
374 _Base::equal_range(__x);
376 iterator(__res.
second,
this));
380 equal_range(
const key_type& __x)
const
383 _Base::equal_range(__x);
385 const_iterator(__res.
second,
this));
389 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
392 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
403 template<
typename _Key,
typename _Tp,
404 typename _Compare,
typename _Allocator>
408 {
return __lhs._M_base() == __rhs._M_base(); }
410 template<
typename _Key,
typename _Tp,
411 typename _Compare,
typename _Allocator>
415 {
return __lhs._M_base() != __rhs._M_base(); }
417 template<
typename _Key,
typename _Tp,
418 typename _Compare,
typename _Allocator>
420 operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
421 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
422 {
return __lhs._M_base() < __rhs._M_base(); }
424 template<
typename _Key,
typename _Tp,
425 typename _Compare,
typename _Allocator>
427 operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
428 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
429 {
return __lhs._M_base() <= __rhs._M_base(); }
431 template<
typename _Key,
typename _Tp,
432 typename _Compare,
typename _Allocator>
434 operator>=(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
435 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
436 {
return __lhs._M_base() >= __rhs._M_base(); }
438 template<
typename _Key,
typename _Tp,
439 typename _Compare,
typename _Allocator>
441 operator>(
const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
442 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
443 {
return __lhs._M_base() > __rhs._M_base(); }
445 template<
typename _Key,
typename _Tp,
446 typename _Compare,
typename _Allocator>
448 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
449 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
450 { __lhs.swap(__rhs); }
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
#define __glibcxx_check_erase_range(_First, _Last)
_T2 second
first is a copy of the first object
#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.
Base class for constructing a safe sequence type that tracks iterators that reference it...
void _M_invalidate_if(_Predicate __pred)
#define __glibcxx_check_insert(_Position)
void _M_swap(_Safe_sequence_base &__x)
Class std::multimap with safety/checking/debug instrumentation.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
_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.
_Iterator base() const
Return the underlying iterator.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
Struct holding two objects of arbitrary type.