Patch for stl_tree.h and cpp_type_traits.h.

Dhruv Matani dhruvbird@gmx.net
Wed Feb 18 04:22:00 GMT 2004


On Wed, 2004-02-18 at 00:42, Gawain Bolton wrote:
> Hi Dhruv,
> 
> I think your proposed changes to stl_tree.h can go a little bit further to
> simplifying things...
> 
> The _Rb_tree_impl class constructor can be added to so that the
> _M_empty_initialize() function can be removed entirely.

Meaning that I include the code for the _M_empty_initialize() function
within the ctor for the _Rb_tree_impl class? Thinking about it, it can
be done because as it is, Leftmost and Rightmost are the left and right
children of the dummy node, and the root is the parent pointer, but
would it become noticeable at first reading? Some new person like me
reading the code for the first time would not find it easy? (As it is I
found it not that easy ;-)). Possibly, if no one disagrees! Any
comments?



> This will allow the copy constructor can be simplified to something like:
> _Rb_tree(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x)
>  : _M_impl(__x.get_allocator(), __x._M_impl._M_key_compare())
> {
>   if (__x._M_root() != 0)
>   {
>     _M_root() = _M_copy(__x._M_begin(), _M_end());
>     _M_leftmost() = _S_minimum(_M_root());
>     _M_rightmost() = _S_maximum(_M_root());
>     _M_impl._M_node_count = __x._M_impl._M_node_count;
>   }
> }
> 
> Cheers,
> 
> Gawain
-- 
	-Dhruv Matani.
http://www.geocities.com/dhruvbird/





More information about the Libstdc++ mailing list