===================================================================
@@ -212,7 +212,7 @@
#endif
iterator
- insert(iterator __position, const value_type& __x)
+ insert(const_iterator __position, const value_type& __x)
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(), __x), this);
@@ -245,7 +245,7 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __position)
+ erase(const_iterator __position)
{
__glibcxx_check_erase(__position);
__position._M_invalidate();
@@ -277,14 +277,14 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __first, iterator __last)
+ erase(const_iterator __first, const_iterator __last)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last);
while (__first != __last)
this->erase(__first++);
- return __last;
+ return __last; // iterator == const_iterator
}
#else
void
===================================================================
@@ -201,7 +201,7 @@
#endif
iterator
- insert(iterator __position, const value_type& __x)
+ insert(const_iterator __position, const value_type& __x)
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(), __x), this);
@@ -234,7 +234,7 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __position)
+ erase(const_iterator __position)
{
__glibcxx_check_erase(__position);
__position._M_invalidate();
@@ -267,14 +267,14 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __first, iterator __last)
+ erase(const_iterator __first, const_iterator __last)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last);
while (__first != __last)
this->erase(__first++);
- return __last;
+ return __last; // iterator == const_iterator
}
#else
void
===================================================================
@@ -232,7 +232,11 @@
#endif
iterator
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ insert(const_iterator __position, const value_type& __x)
+#else
insert(iterator __position, const value_type& __x)
+#endif
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(), __x), this);
@@ -262,7 +266,7 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __position)
+ erase(const_iterator __position)
{
__glibcxx_check_erase(__position);
__position._M_invalidate();
@@ -294,14 +298,14 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __first, iterator __last)
+ erase(const_iterator __first, const_iterator __last)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last);
while (__first != __last)
this->erase(__first++);
- return __last;
+ return iterator(__last.base()._M_const_cast(), this);
}
#else
void
===================================================================
@@ -213,7 +213,11 @@
#endif
iterator
- insert(iterator __position, const value_type& __x)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ insert(const_iterator __position, const value_type& __x)
+#else
+ insert(iterator __position, const value_type& __x)
+#endif
{
__glibcxx_check_insert(__position);
return iterator(_Base::insert(__position.base(), __x), this);
@@ -243,7 +247,7 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __position)
+ erase(const_iterator __position)
{
__glibcxx_check_erase(__position);
__position._M_invalidate();
@@ -276,14 +280,14 @@
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iterator
- erase(iterator __first, iterator __last)
+ erase(const_iterator __first, const_iterator __last)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last);
while (__first != __last)
this->erase(__first++);
- return __last;
+ return iterator(__last.base()._M_const_cast(), this);
}
#else
void
===================================================================
@@ -201,11 +201,7 @@
#endif
iterator
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
-#else
- insert(iterator __position, const value_type& __x)
-#endif
{ return iterator(_Base::insert(__position, __x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
===================================================================
@@ -190,11 +190,7 @@
#endif
iterator
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
-#else
- insert(iterator __position, const value_type& __x)
-#endif
{ return iterator(_Base::insert(__position, __x)); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
===================================================================
@@ -439,11 +439,7 @@
* Insertion requires logarithmic time (if the hint is not taken).
*/
iterator
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
-#else
- insert(iterator __position, const value_type& __x)
-#endif
{ return _M_t._M_insert_unique_(__position, __x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
===================================================================
@@ -423,11 +423,7 @@
* Insertion requires logarithmic time (if the hint is not taken).
*/
iterator
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
insert(const_iterator __position, const value_type& __x)
-#else
- insert(iterator __position, const value_type& __x)
-#endif
{ return _M_t._M_insert_equal_(__position, __x); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
===================================================================
@@ -247,6 +247,11 @@
_Rb_tree_const_iterator(const iterator& __it)
: _M_node(__it._M_node) { }
+ iterator
+ _M_const_cast() const
+ { return iterator(static_cast<typename iterator::_Link_type>
+ (const_cast<typename iterator::_Base_ptr>(_M_node))); }
+
reference
operator*() const
{ return static_cast<_Link_type>(_M_node)->_M_value_field; }
@@ -556,11 +561,6 @@
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
private:
- iterator
- _M_const_cast_iter(const_iterator __cit)
- { return iterator(static_cast<_Link_type>
- (const_cast<_Base_ptr>(__cit._M_node))); }
-
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
iterator
@@ -756,7 +756,7 @@
const_iterator __result = __position;
++__result;
_M_erase_aux(__position);
- return _M_const_cast_iter(__result);
+ return __result._M_const_cast();
}
#else
void
@@ -773,7 +773,7 @@
erase(const_iterator __first, const_iterator __last)
{
_M_erase_aux(__first, __last);
- return _M_const_cast_iter(__last);
+ return __last._M_const_cast();
}
#else
void
@@ -1364,7 +1364,7 @@
}
else
// Equivalent keys.
- return _M_const_cast_iter(__position);
+ return __position._M_const_cast();
}
template<typename _Key, typename _Val, typename _KeyOfValue,