This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Jonathan Wakely <cow@compsoc.man.ac.uk> writes:

| On Fri, Jul 25, 2003 at 10:10:11AM +0100, Jonathan Wakely wrote:
| 
| > 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
| 
| [replying to myself]
| hmm, no. for example _M_root() wants to return a non-const reference,
| which can't be bound to the rvalue that static_cast returns.
| The old parser didn't seem to mind this (or at least, versions <= 3.2)
| but 3.4 won't allow it.

Note that if you make _M_root a static member function and pass it a
pointer, you can convert and  dereference it and get an lvalue.  Also
variability in const-qualifier will be part of the type of the pointee
and there won't be any need to duplicate the function.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]