[Patch] PR11504: -Wcast-qual and general constness issues with stl_tree.h

Jonathan Wakely cow@compsoc.man.ac.uk
Fri Jul 25 09:10:00 GMT 2003

On Thu, Jul 24, 2003 at 09:48:07PM +0200, Gawain Bolton wrote:

>   1. I do not like the lack of symmetry with the casts for const vs.
>      non-const functions.
>      Non-const versions often require a reinterpret_cast whereas const
>      versions can use static_cast.

Can't you combine const_cast and static_cast to achieve the same thing?
As in http://gcc.gnu.org/ml/libstdc++/2003-07/msg00297.html

>   2. The "const" typedefs.
>      Why do I have to define "const" versions of the typedefs?
>      If I have "typedef _Rb_tree_node* _Link_type;" then why can't I
>      use "const _Link_type" instead of having to define an explicit
>      const typedef like "typedef const _Rb_tree_node* _const_Link_type;"?

Because "const _Link_type" is the same as "_Link_type const" which is
"_Rb_tree_node* const" which is a const-pointer to a non-const-node,
not a pointer to a const-node.

Now repeat that six times as fast as you can!  :-)


"Once, during Prohibition, I was forced to live for days on nothing but 
 food and water."
	- W.C. Fields

More information about the Libstdc++ mailing list