[cfe-dev] Creating New Types

Bill Wendling isanbard at gmail.com
Tue Aug 7 13:10:35 PDT 2007


On 8/7/07, Chris Lattner <clattner at apple.com> wrote:
> >> (This is related to the description of "casting away constness" in
> >> the C++ standard [5.2.11p8].)
> >
> > How so?  const_cast should never change the underlying type (e.g.
> > from float to char).  In fact, my understanding of const cast is that
> > it isn't a "recursive" process, it just looks at the top-level
> > qualifiers and pointer/reference.
>
> Actually, const_cast has to *compare* the src and dest type
> recursively, but I still don't think it has to *reconstruct* a mix of
> the two.
>
It seemed to say that if one pointer type with N pointers could be
implicitly cast to a "subtype" of another pointer type with M
pointers, where N < M for some type T, then we aren't casting away
constness. That's what I was doing with my example. I was going to use
the implicit cast checking stuff to make sure that this is valid. I
suppose it's possible to compare it recursively, if I can make sure
that the checking is valid for each step.

-bw



More information about the cfe-dev mailing list