[RFC] Two versions of struct _Rb_tree_impl... or not?!

Paolo Carlini pcarlini@suse.de
Mon Jul 5 21:03:00 GMT 2004


Hi,

I'm reading the following, rather new, code, and would appreciate some help
understanding what is supposed to achieve, in principle, at least

////////////////

   template<typename _Key_compare,
            bool _Is_pod_comparator = std::__is_pod<_Key_compare>::_M_type>
     struct _Rb_tree_impl : public _Node_allocator
     {
       _Key_compare        _M_key_compare;
       _Rb_tree_node_base  _M_header;
       size_type           _M_node_count; // Keeps track of size of tree.

       _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(),
                     const _Key_compare& __comp = _Key_compare())
       : _Node_allocator(__a), _M_key_compare(__comp), _M_node_count(0)
       {
         this->_M_header._M_color = _S_red;
         this->_M_header._M_parent = 0;
         this->_M_header._M_left = &this->_M_header;
         this->_M_header._M_right = &this->_M_header;
       }
     };

   // Specialization for _Comparison types that are not capable of
   // being base classes / super classes.
   template<typename _Key_compare>
     struct _Rb_tree_impl<_Key_compare, true> : public _Node_allocator
     {
       _Key_compare         _M_key_compare;
       _Rb_tree_node_base   _M_header;
       size_type            _M_node_count; // Keeps track of size of tree.

       _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(),
                     const _Key_compare& __comp = _Key_compare())
       : _Node_allocator(__a), _M_key_compare(__comp), _M_node_count(0)
       {
         this->_M_header._M_color = _S_red;
         this->_M_header._M_parent = 0;
         this->_M_header._M_left = &this->_M_header;
         this->_M_header._M_right = &this->_M_header;
       }
     };

/////////////////

I gather that something went wrong with the original idea and now we end
up having a specialization that is a duplicate of the primary template :(

I would like to help fixing this, but it's too difficult for me without
knowing the original "good intentions" ;) ...

Thanks in advance,
Paolo.



More information about the Libstdc++ mailing list