Commit 7606bd11 by Paolo Carlini Committed by Paolo Carlini

stl_tree.h (_Rb_tree<>::_M_erase_aux): Add.

2010-11-08  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/stl_tree.h (_Rb_tree<>::_M_erase_aux): Add.
	(_Rb_tree<>::erase(iterator)): Fix in C++0x mode to take
	const_iterator; remove redundant overload in C++03 mode.
	(_Rb_tree<>::erase(iterator, iterator)): Likewise.
	* include/bits/stl_map.h (map<>::erase): Adjust.
	(map<>::insert): Fix signature in C++0x mode.
	* include/bits/stl_set.h (set<>::erase): Likewise.
	(set<>::insert): Likewise.
	* include/bits/stl_multimap.h (multimap<>::erase): Likewise.
	(multimap<>::insert): Likewise.
	* include/bits/stl_multiset.h (multiset<>::erase): Likewise.
	(multiset<>::insert): Fix signature in C++0x mode.
	* include/profile/set.h: Adjust.
	* include/profile/multiset.h: Likewise.
	* include/profile/map.h: Likewise.
	* include/profile/multimap.h: Likewise.
	* testsuite/util/exception/safety.h (erase_base, insert_base):
	Update.

From-SVN: r166438
parent 7876e2b5
2010-11-08 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_tree.h (_Rb_tree<>::_M_erase_aux): Add.
(_Rb_tree<>::erase(iterator)): Fix in C++0x mode to take
const_iterator; remove redundant overload in C++03 mode.
(_Rb_tree<>::erase(iterator, iterator)): Likewise.
* include/bits/stl_map.h (map<>::erase): Adjust.
(map<>::insert): Fix signature in C++0x mode.
* include/bits/stl_set.h (set<>::erase): Likewise.
(set<>::insert): Likewise.
* include/bits/stl_multimap.h (multimap<>::erase): Likewise.
(multimap<>::insert): Likewise.
* include/bits/stl_multiset.h (multiset<>::erase): Likewise.
(multiset<>::insert): Fix signature in C++0x mode.
* include/profile/set.h: Adjust.
* include/profile/multiset.h: Likewise.
* include/profile/map.h: Likewise.
* include/profile/multimap.h: Likewise.
* testsuite/util/exception/safety.h (erase_base, insert_base):
Update.
2010-11-07 Paolo Carlini <paolo.carlini@oracle.com> 2010-11-07 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/unordered_map (unordered_map<>::operator[](_Key&&)): * include/profile/unordered_map (unordered_map<>::operator[](_Key&&)):
......
...@@ -510,7 +510,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -510,7 +510,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
*/ */
void void
insert(std::initializer_list<value_type> __list) insert(std::initializer_list<value_type> __list)
{ insert (__list.begin(), __list.end()); } { insert(__list.begin(), __list.end()); }
#endif #endif
/** /**
...@@ -537,7 +537,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -537,7 +537,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* Insertion requires logarithmic time (if the hint is not taken). * Insertion requires logarithmic time (if the hint is not taken).
*/ */
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
#endif
{ return _M_t._M_insert_unique_(__position, __x); } { return _M_t._M_insert_unique_(__position, __x); }
/** /**
...@@ -570,7 +574,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -570,7 +574,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* the pointer is the user's responsibility. * the pointer is the user's responsibility.
*/ */
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _M_t.erase(__position); } { return _M_t.erase(__position); }
#else #else
/** /**
...@@ -619,7 +623,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -619,7 +623,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* in any way. Managing the pointer is the user's responsibility. * in any way. Managing the pointer is the user's responsibility.
*/ */
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); } { return _M_t.erase(__first, __last); }
#else #else
/** /**
......
...@@ -459,7 +459,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -459,7 +459,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* Insertion requires logarithmic time (if the hint is not taken). * Insertion requires logarithmic time (if the hint is not taken).
*/ */
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
#endif
{ return _M_t._M_insert_equal_(__position, __x); } { return _M_t._M_insert_equal_(__position, __x); }
/** /**
...@@ -506,7 +510,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -506,7 +510,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* responsibility. * responsibility.
*/ */
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _M_t.erase(__position); } { return _M_t.erase(__position); }
#else #else
/** /**
...@@ -552,10 +556,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -552,10 +556,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This function erases a sequence of elements from a %multimap. * This function erases a sequence of elements from a %multimap.
* Note that this function only erases the elements, and that if * Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not * the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's responsibility. * touched in any way. Managing the pointer is the user's
* responsibility.
*/ */
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); } { return _M_t.erase(__first, __last); }
#else #else
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
...@@ -569,7 +574,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -569,7 +574,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This function erases a sequence of elements from a %multimap. * This function erases a sequence of elements from a %multimap.
* Note that this function only erases the elements, and that if * Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not * the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's responsibility. * touched in any way. Managing the pointer is the user's
* responsibility.
*/ */
void void
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
......
...@@ -417,7 +417,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -417,7 +417,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* Insertion requires logarithmic time (if the hint is not taken). * Insertion requires logarithmic time (if the hint is not taken).
*/ */
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
#endif
{ return _M_t._M_insert_equal_(__position, __x); } { return _M_t._M_insert_equal_(__position, __x); }
/** /**
...@@ -463,7 +467,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -463,7 +467,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* responsibility. * responsibility.
*/ */
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _M_t.erase(__position); } { return _M_t.erase(__position); }
#else #else
/** /**
...@@ -509,10 +513,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -509,10 +513,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This function erases a sequence of elements from a %multiset. * This function erases a sequence of elements from a %multiset.
* Note that this function only erases the elements, and that if * Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not * the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's responsibility. * touched in any way. Managing the pointer is the user's
* responsibility.
*/ */
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); } { return _M_t.erase(__first, __last); }
#else #else
/** /**
...@@ -524,7 +529,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -524,7 +529,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This function erases a sequence of elements from a %multiset. * This function erases a sequence of elements from a %multiset.
* Note that this function only erases the elements, and that if * Note that this function only erases the elements, and that if
* the elements themselves are pointers, the pointed-to memory is not * the elements themselves are pointers, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's responsibility. * touched in any way. Managing the pointer is the user's
* responsibility.
*/ */
void void
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
......
...@@ -429,7 +429,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -429,7 +429,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* Insertion requires logarithmic time (if the hint is not taken). * Insertion requires logarithmic time (if the hint is not taken).
*/ */
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
#endif
{ return _M_t._M_insert_unique_(__position, __x); } { return _M_t._M_insert_unique_(__position, __x); }
/** /**
...@@ -472,10 +476,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -472,10 +476,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This function erases an element, pointed to by the given iterator, * This function erases an element, pointed to by the given iterator,
* from a %set. Note that this function only erases the element, and * from a %set. Note that this function only erases the element, and
* that if the element is itself a pointer, the pointed-to memory is not * that if the element is itself a pointer, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's responsibility. * touched in any way. Managing the pointer is the user's
* responsibility.
*/ */
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _M_t.erase(__position); } { return _M_t.erase(__position); }
#else #else
/** /**
...@@ -485,7 +490,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -485,7 +490,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This function erases an element, pointed to by the given iterator, * This function erases an element, pointed to by the given iterator,
* from a %set. Note that this function only erases the element, and * from a %set. Note that this function only erases the element, and
* that if the element is itself a pointer, the pointed-to memory is not * that if the element is itself a pointer, the pointed-to memory is not
* touched in any way. Managing the pointer is the user's responsibility. * touched in any way. Managing the pointer is the user's
* responsibility.
*/ */
void void
erase(iterator __position) erase(iterator __position)
...@@ -523,7 +529,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) ...@@ -523,7 +529,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* in any way. Managing the pointer is the user's responsibility. * in any way. Managing the pointer is the user's responsibility.
*/ */
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ return _M_t.erase(__first, __last); } { return _M_t.erase(__first, __last); }
#else #else
/** /**
......
...@@ -702,22 +702,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -702,22 +702,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void void
_M_insert_equal(_InputIterator __first, _InputIterator __last); _M_insert_equal(_InputIterator __first, _InputIterator __last);
private:
void
_M_erase_aux(const_iterator __position);
void
_M_erase_aux(const_iterator __first, const_iterator __last);
public:
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator. // DR 130. Associative erase should return an iterator.
iterator iterator
erase(iterator __position); erase(const_iterator __position)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS const_iterator __result = __position;
// DR 130. Associative erase should return an iterator. ++__result;
const_iterator _M_erase_aux(__position);
erase(const_iterator __position); return iterator(static_cast<_Link_type>
(const_cast<_Base_ptr>(__result._M_node)));
}
#else #else
void void
erase(iterator __position); erase(const_iterator __position)
{ _M_erase_aux(__position); }
void
erase(const_iterator __position);
#endif #endif
size_type size_type
erase(const key_type& __x); erase(const key_type& __x);
...@@ -726,18 +734,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -726,18 +734,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator. // DR 130. Associative erase should return an iterator.
iterator iterator
erase(iterator __first, iterator __last); erase(const_iterator __first, const_iterator __last)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS _M_erase_aux(__first, __last);
// DR 130. Associative erase should return an iterator. return iterator(static_cast<_Link_type>
const_iterator (const_cast<_Base_ptr>(__last._M_node)));
erase(const_iterator __first, const_iterator __last); }
#else #else
void void
erase(iterator __first, iterator __last); erase(const_iterator __first, const_iterator __last)
{ _M_erase_aux(__first, __last); }
void
erase(const_iterator __first, const_iterator __last);
#endif #endif
void void
erase(const key_type* __first, const key_type* __last); erase(const key_type* __first, const key_type* __last);
...@@ -1353,64 +1359,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1353,64 +1359,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_insert_equal_(end(), *__first); _M_insert_equal_(end(), *__first);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator void
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(iterator __position)
{
iterator __result = __position;
++__result;
_Link_type __y =
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
(__position._M_node,
this->_M_impl._M_header));
_M_destroy_node(__y);
--_M_impl._M_node_count;
return __result;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(const_iterator __position)
{
const_iterator __result = __position;
++__result;
_Link_type __y =
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
(const_cast<_Base_ptr>(__position._M_node),
this->_M_impl._M_header));
_M_destroy_node(__y);
--_M_impl._M_node_count;
return __result;
}
#else
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
inline void
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(iterator __position)
{
_Link_type __y =
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
(__position._M_node,
this->_M_impl._M_header));
_M_destroy_node(__y);
--_M_impl._M_node_count;
}
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
inline void
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(const_iterator __position) _M_erase_aux(const_iterator __position)
{ {
_Link_type __y = _Link_type __y =
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase static_cast<_Link_type>(_Rb_tree_rebalance_for_erase
...@@ -1419,68 +1372,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1419,68 +1372,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_destroy_node(__y); _M_destroy_node(__y);
--_M_impl._M_node_count; --_M_impl._M_node_count;
} }
#endif
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(const _Key& __x)
{
pair<iterator, iterator> __p = equal_range(__x);
const size_type __old_size = size();
erase(__p.first, __p.second);
return __old_size - size();
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(iterator __first, iterator __last)
{
if (__first == begin() && __last == end())
{
clear();
return end();
}
else
{
while (__first != __last)
erase(__first++);
return __last;
}
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 130. Associative erase should return an iterator.
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(const_iterator __first, const_iterator __last)
{
if (__first == begin() && __last == end())
{
clear();
return end();
}
else
{
while (__first != __last)
erase(__first++);
return __last;
}
}
#else
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
void void
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(iterator __first, iterator __last) _M_erase_aux(const_iterator __first, const_iterator __last)
{ {
if (__first == begin() && __last == end()) if (__first == begin() && __last == end())
clear(); clear();
...@@ -1491,17 +1388,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1491,17 +1388,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
void typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
erase(const_iterator __first, const_iterator __last) erase(const _Key& __x)
{ {
if (__first == begin() && __last == end()) pair<iterator, iterator> __p = equal_range(__x);
clear(); const size_type __old_size = size();
else erase(__p.first, __p.second);
while (__first != __last) return __old_size - size();
erase(__first++);
} }
#endif
template<typename _Key, typename _Val, typename _KeyOfValue, template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
......
...@@ -251,17 +251,22 @@ namespace __profile ...@@ -251,17 +251,22 @@ namespace __profile
size_type size_before = size(); size_type size_before = size();
_Base::insert(__list); _Base::insert(__list);
__profcxx_map_to_unordered_map_insert(this, size_before, __profcxx_map_to_unordered_map_insert(this, size_before,
size() - size_before); size() - size_before);
} }
#endif #endif
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
#endif
{ {
size_type size_before = size(); size_type size_before = size();
return iterator(_Base::insert(__position, __x)); iterator __i = iterator(_Base::insert(__position, __x));
__profcxx_map_to_unordered_map_insert(this, size_before, __profcxx_map_to_unordered_map_insert(this, size_before,
size() - size_before); size() - size_before);
return __i;
} }
template<typename _InputIterator> template<typename _InputIterator>
...@@ -276,7 +281,7 @@ namespace __profile ...@@ -276,7 +281,7 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ {
iterator __i = _Base::erase(__position); iterator __i = _Base::erase(__position);
__profcxx_map_to_unordered_map_erase(this, size(), 1); __profcxx_map_to_unordered_map_erase(this, size(), 1);
...@@ -306,31 +311,18 @@ namespace __profile ...@@ -306,31 +311,18 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ { return iterator(_Base::erase(__first, __last)); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
return __last;
}
#else #else
void void
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ { _Base::erase(__first, __last); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
}
#endif #endif
void void
swap(map& __x) swap(map& __x)
{ { _Base::swap(__x); }
_Base::swap(__x);
}
void void
clear() clear()
......
...@@ -192,22 +192,22 @@ namespace __profile ...@@ -192,22 +192,22 @@ namespace __profile
#endif #endif
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
{ #endif
return iterator(_Base::insert(__position, __x)); { return iterator(_Base::insert(__position, __x)); }
}
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ { _Base::insert(__first, __last); }
_Base::insert(__first, __last);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _Base::erase(__position); } { return iterator(_Base::erase(__position)); }
#else #else
void void
erase(iterator __position) erase(iterator __position)
...@@ -230,30 +230,17 @@ namespace __profile ...@@ -230,30 +230,17 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ { return iterator(_Base::erase(__first, __last)); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
return __last;
}
#else #else
void void
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ { _Base::erase(__first, __last); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
}
#endif #endif
void void
swap(multimap& __x) swap(multimap& __x)
{ { _Base::swap(__x); }
_Base::swap(__x);
}
void void
clear() clear()
......
...@@ -184,17 +184,17 @@ namespace __profile ...@@ -184,17 +184,17 @@ namespace __profile
{ return iterator(_Base::insert(__x)); } { return iterator(_Base::insert(__x)); }
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
{ #endif
return iterator(_Base::insert(__position, __x)); { return iterator(_Base::insert(__position, __x)); }
}
template<typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ { _Base::insert(__first, __last); }
_Base::insert(__first, __last);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
void void
...@@ -204,8 +204,8 @@ namespace __profile ...@@ -204,8 +204,8 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _Base::erase(__position); } { return iterator(_Base::erase(__position)); }
#else #else
void void
erase(iterator __position) erase(iterator __position)
...@@ -228,30 +228,17 @@ namespace __profile ...@@ -228,30 +228,17 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ { return iterator(_Base::erase(__first, __last)); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
return __last;
}
#else #else
void void
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ { _Base::erase(__first, __last); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
}
#endif #endif
void void
swap(multiset& __x) swap(multiset& __x)
{ { _Base::swap(__x); }
_Base::swap(__x);
}
void void
clear() clear()
......
...@@ -189,17 +189,17 @@ namespace __profile ...@@ -189,17 +189,17 @@ namespace __profile
} }
iterator iterator
#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
{ #endif
return iterator(_Base::insert(__position, __x)); { return iterator(_Base::insert(__position, __x)); }
}
template <typename _InputIterator> template <typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ { _Base::insert(__first, __last); }
_Base::insert(__first, __last);
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
void void
...@@ -209,8 +209,8 @@ namespace __profile ...@@ -209,8 +209,8 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __position) erase(const_iterator __position)
{ return _Base::erase(__position); } { return iterator(_Base::erase(__position)); }
#else #else
void void
erase(iterator __position) erase(iterator __position)
...@@ -232,30 +232,17 @@ namespace __profile ...@@ -232,30 +232,17 @@ namespace __profile
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator iterator
erase(iterator __first, iterator __last) erase(const_iterator __first, const_iterator __last)
{ { return iterator(_Base::erase(__first, __last)); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
return __last;
}
#else #else
void void
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ { _Base::erase(__first, __last); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
while (__first != __last)
this->erase(__first++);
}
#endif #endif
void void
swap(set& __x) swap(set& __x)
{ { _Base::swap(__x); }
_Base::swap(__x);
}
void void
clear() clear()
......
...@@ -251,91 +251,93 @@ namespace __gnu_test ...@@ -251,91 +251,93 @@ namespace __gnu_test
struct erase_base struct erase_base
{ {
typedef typename _Tp::iterator iterator; typedef typename _Tp::iterator iterator;
typedef typename _Tp::const_iterator const_iterator;
iterator (_Tp::* _F_erase_point)(iterator); iterator (_Tp::* _F_erase_point)(const_iterator);
iterator (_Tp::* _F_erase_range)(iterator, iterator); iterator (_Tp::* _F_erase_range)(const_iterator, const_iterator);
erase_base() erase_base()
: _F_erase_point(&_Tp::erase), _F_erase_range(&_Tp::erase) { } : _F_erase_point(&_Tp::erase), _F_erase_range(&_Tp::erase) { }
}; };
// Specialization, as forward_list has erase_after. // Specializations, old C++03 signatures.
template<typename _Tp1, typename _Tp2> template<typename _Tp1, typename _Tp2, typename _Tp3>
struct erase_base<std::forward_list<_Tp1, _Tp2>> struct erase_base<std::basic_string<_Tp1, _Tp2, _Tp3>>
{ {
typedef std::forward_list<_Tp1, _Tp2> container_type; typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
iterator (container_type::* _F_erase_point)(const_iterator); iterator (container_type::* _F_erase_point)(iterator);
iterator (container_type::* _F_erase_range)(const_iterator, iterator (container_type::* _F_erase_range)(iterator, iterator);
const_iterator);
erase_base() erase_base()
: _F_erase_point(&container_type::erase_after), : _F_erase_point(&container_type::erase),
_F_erase_range(&container_type::erase_after) { } _F_erase_range(&container_type::erase) { }
}; };
// Specializations for the unordered containers.
template<typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp1, typename _Tp2, typename _Tp3,
typename _Tp4, typename _Tp5> template <typename, typename, typename> class _Tp4>
struct erase_base<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>> struct erase_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
{ {
typedef std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>
container_type; container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
iterator (container_type::* _F_erase_point)(const_iterator); iterator (container_type::* _F_erase_point)(iterator);
iterator (container_type::* _F_erase_range)(const_iterator, iterator (container_type::* _F_erase_range)(iterator, iterator);
const_iterator);
erase_base() erase_base()
: _F_erase_point(&container_type::erase), : _F_erase_point(&container_type::erase),
_F_erase_range(&container_type::erase) { } _F_erase_range(&container_type::erase) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp1, typename _Tp2>
typename _Tp4, typename _Tp5> struct erase_base<std::deque<_Tp1, _Tp2>>
struct erase_base<std::unordered_multimap<_Tp1, _Tp2, _Tp3,
_Tp4, _Tp5>>
{ {
typedef std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> typedef std::deque<_Tp1, _Tp2> container_type;
container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
iterator (container_type::* _F_erase_point)(const_iterator); iterator (container_type::* _F_erase_point)(iterator);
iterator (container_type::* _F_erase_range)(const_iterator, iterator (container_type::* _F_erase_range)(iterator, iterator);
const_iterator);
erase_base()
: _F_erase_point(&container_type::erase),
_F_erase_range(&container_type::erase) { }
};
template<typename _Tp1, typename _Tp2>
struct erase_base<std::list<_Tp1, _Tp2>>
{
typedef std::list<_Tp1, _Tp2> container_type;
typedef typename container_type::iterator iterator;
iterator (container_type::* _F_erase_point)(iterator);
iterator (container_type::* _F_erase_range)(iterator, iterator);
erase_base() erase_base()
: _F_erase_point(&container_type::erase), : _F_erase_point(&container_type::erase),
_F_erase_range(&container_type::erase) { } _F_erase_range(&container_type::erase) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> template<typename _Tp1, typename _Tp2>
struct erase_base<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>> struct erase_base<std::vector<_Tp1, _Tp2>>
{ {
typedef std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4> typedef std::vector<_Tp1, _Tp2> container_type;
container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
iterator (container_type::* _F_erase_point)(const_iterator); iterator (container_type::* _F_erase_point)(iterator);
iterator (container_type::* _F_erase_range)(const_iterator, iterator (container_type::* _F_erase_range)(iterator, iterator);
const_iterator);
erase_base() erase_base()
: _F_erase_point(&container_type::erase), : _F_erase_point(&container_type::erase),
_F_erase_range(&container_type::erase) { } _F_erase_range(&container_type::erase) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> // Specialization, as forward_list has erase_after.
struct erase_base<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>> template<typename _Tp1, typename _Tp2>
struct erase_base<std::forward_list<_Tp1, _Tp2>>
{ {
typedef std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4> typedef std::forward_list<_Tp1, _Tp2> container_type;
container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator; typedef typename container_type::const_iterator const_iterator;
...@@ -344,8 +346,8 @@ namespace __gnu_test ...@@ -344,8 +346,8 @@ namespace __gnu_test
const_iterator); const_iterator);
erase_base() erase_base()
: _F_erase_point(&container_type::erase), : _F_erase_point(&container_type::erase_after),
_F_erase_range(&container_type::erase) { } _F_erase_range(&container_type::erase_after) { }
}; };
template<typename _Tp, template<typename _Tp,
...@@ -633,109 +635,87 @@ namespace __gnu_test ...@@ -633,109 +635,87 @@ namespace __gnu_test
struct insert_base struct insert_base
{ {
typedef typename _Tp::iterator iterator; typedef typename _Tp::iterator iterator;
typedef typename _Tp::const_iterator const_iterator;
typedef typename _Tp::value_type value_type; typedef typename _Tp::value_type value_type;
iterator (_Tp::* _F_insert_point)(iterator, const value_type&); iterator (_Tp::* _F_insert_point)(const_iterator, const value_type&);
insert_base() : _F_insert_point(&_Tp::insert) { } insert_base() : _F_insert_point(&_Tp::insert) { }
}; };
// Specialization, as string insertion has a different signature. // Specializations, old C++03 signatures.
template<typename _Tp1, typename _Tp2, typename _Tp3> template<typename _Tp1, typename _Tp2>
struct insert_base<std::basic_string<_Tp1, _Tp2, _Tp3>> struct insert_base<std::deque<_Tp1, _Tp2>>
{ {
typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type; typedef std::deque<_Tp1, _Tp2> container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::value_type value_type; typedef typename container_type::value_type value_type;
iterator (container_type::* _F_insert_point)(iterator, value_type); iterator (container_type::* _F_insert_point)(iterator,
const value_type&);
insert_base() : _F_insert_point(&container_type::insert) { } insert_base() : _F_insert_point(&container_type::insert) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, template<typename _Tp1, typename _Tp2>
template <typename, typename, typename> class _Tp4> struct insert_base<std::list<_Tp1, _Tp2>>
struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
{ {
typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4> typedef std::list<_Tp1, _Tp2> container_type;
container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::value_type value_type; typedef typename container_type::value_type value_type;
iterator (container_type::* _F_insert_point)(iterator, value_type); iterator (container_type::* _F_insert_point)(iterator,
const value_type&);
insert_base() : _F_insert_point(&container_type::insert) { } insert_base() : _F_insert_point(&container_type::insert) { }
}; };
// Specialization, as forward_list insertion has a different signature.
template<typename _Tp1, typename _Tp2> template<typename _Tp1, typename _Tp2>
struct insert_base<std::forward_list<_Tp1, _Tp2>> struct insert_base<std::vector<_Tp1, _Tp2>>
{ {
typedef std::forward_list<_Tp1, _Tp2> container_type; typedef std::vector<_Tp1, _Tp2> container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::value_type value_type; typedef typename container_type::value_type value_type;
iterator (container_type::* _F_insert_point)(const_iterator, iterator (container_type::* _F_insert_point)(iterator,
const value_type&);
insert_base() : _F_insert_point(&container_type::insert_after) { }
};
// Likewise for the unordered containers.
template<typename _Tp1, typename _Tp2, typename _Tp3,
typename _Tp4, typename _Tp5>
struct insert_base<std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>>
{
typedef std::unordered_map<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5>
container_type;
typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::value_type value_type;
iterator (container_type::* _F_insert_point)(const_iterator,
const value_type&); const value_type&);
insert_base() : _F_insert_point(&container_type::insert) { } insert_base() : _F_insert_point(&container_type::insert) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, // Specialization, as string insertion has a different signature.
typename _Tp4, typename _Tp5> template<typename _Tp1, typename _Tp2, typename _Tp3>
struct insert_base<std::unordered_multimap<_Tp1, _Tp2, _Tp3, struct insert_base<std::basic_string<_Tp1, _Tp2, _Tp3>>
_Tp4, _Tp5>>
{ {
typedef std::unordered_multimap<_Tp1, _Tp2, _Tp3, _Tp4, _Tp5> typedef std::basic_string<_Tp1, _Tp2, _Tp3> container_type;
container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::value_type value_type; typedef typename container_type::value_type value_type;
iterator (container_type::* _F_insert_point)(const_iterator, iterator (container_type::* _F_insert_point)(iterator, value_type);
const value_type&);
insert_base() : _F_insert_point(&container_type::insert) { } insert_base() : _F_insert_point(&container_type::insert) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> // Likewise for __versa_string.
struct insert_base<std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4>> template<typename _Tp1, typename _Tp2, typename _Tp3,
template <typename, typename, typename> class _Tp4>
struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>>
{ {
typedef std::unordered_set<_Tp1, _Tp2, _Tp3, _Tp4> typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>
container_type; container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::value_type value_type; typedef typename container_type::value_type value_type;
iterator (container_type::* _F_insert_point)(const_iterator, iterator (container_type::* _F_insert_point)(iterator, value_type);
const value_type&);
insert_base() : _F_insert_point(&container_type::insert) { } insert_base() : _F_insert_point(&container_type::insert) { }
}; };
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> // Specialization, as forward_list has insert_after.
struct insert_base<std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4>> template<typename _Tp1, typename _Tp2>
struct insert_base<std::forward_list<_Tp1, _Tp2>>
{ {
typedef std::unordered_multiset<_Tp1, _Tp2, _Tp3, _Tp4> typedef std::forward_list<_Tp1, _Tp2> container_type;
container_type;
typedef typename container_type::iterator iterator; typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator; typedef typename container_type::const_iterator const_iterator;
typedef typename container_type::value_type value_type; typedef typename container_type::value_type value_type;
...@@ -743,7 +723,7 @@ namespace __gnu_test ...@@ -743,7 +723,7 @@ namespace __gnu_test
iterator (container_type::* _F_insert_point)(const_iterator, iterator (container_type::* _F_insert_point)(const_iterator,
const value_type&); const value_type&);
insert_base() : _F_insert_point(&container_type::insert) { } insert_base() : _F_insert_point(&container_type::insert_after) { }
}; };
template<typename _Tp, template<typename _Tp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment