Static cast

Jason House at
Wed Jun 25 15:41:36 PDT 2008

Jarrett Billingsley Wrote:

> "Jason House" < at> wrote in message 
> news:g3uedt$1vn0$1 at
> > What is the proper way to implement static cast?
> >
> > cast(T) to shift with an object/ interface hierarchy is dynamic and slow. 
> > My problem is that cast(T)cast(void*) does not honor vtable locations and 
> > ClassInfo is only available at runtime.
> Doesn't honor vtable locations?  Are you talking about trying to cast an 
> interface to a class reference, or an interface to a derived interface? 
> Since that's the only scenario I can think of where the resulting reference 
> would have invalid vtbl locations.  If you're casting from a base *class* to 
> a derived *class*, there is no way AFAIK that it could end up with invalid 
> vtbl entries. 

Yes, interfaces too. You're right that casts to/from an interface is the only problematic scenario.

More information about the Digitalmars-d-learn mailing list