diff mbox

[v3] Minor clean-up to stl_tree.h

Message ID 4CD94B29.4050809@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Nov. 9, 2010, 1:22 p.m. UTC
Hi,

tested x86_64-linux, committed to mainline.

Paolo.

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

	* include/bits/stl_tree.h (_Rb_tree<>::_M_const_cast_iter): Add
	and use it throughout.
diff mbox

Patch

Index: include/bits/stl_tree.h
===================================================================
--- include/bits/stl_tree.h	(revision 166485)
+++ include/bits/stl_tree.h	(working copy)
@@ -557,6 +557,11 @@ 
 
     private:
       iterator
+      _M_const_cast_iter(const_iterator __cit)
+      { return iterator(static_cast<_Link_type>
+			(const_cast<_Base_ptr>(__cit._M_node))); }
+
+      iterator
       _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
 		 const value_type& __v);
 
@@ -719,8 +724,7 @@ 
 	const_iterator __result = __position;
 	++__result;
 	_M_erase_aux(__position);
-	return iterator(static_cast<_Link_type>
-			(const_cast<_Base_ptr>(__result._M_node)));
+	return _M_const_cast_iter(__result);
       }
 #else
       void
@@ -737,8 +741,7 @@ 
       erase(const_iterator __first, const_iterator __last)
       {
 	_M_erase_aux(__first, __last);
-	return iterator(static_cast<_Link_type>
-			(const_cast<_Base_ptr>(__last._M_node)));
+	return _M_const_cast_iter(__last);
       }
 #else
       void
@@ -1279,8 +1282,7 @@ 
 	}
       else
 	// Equivalent keys.
-	return iterator(static_cast<_Link_type>
-			(const_cast<_Base_ptr>(__position._M_node)));
+	return _M_const_cast_iter(__position);
     }
 
   template<typename _Key, typename _Val, typename _KeyOfValue,