Static cast

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Jun 25 15:27:10 PDT 2008


"Jason House" <jason.james.house at gmail.com> wrote in message 
news:g3uedt$1vn0$1 at digitalmars.com...
> 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. 




More information about the Digitalmars-d-learn mailing list