how to determine a runtime type faster?

davidl davidl at 126.com
Thu May 10 19:28:51 PDT 2007


weird, I tested it , it didn't pass last night :o
but this cast feature is exactly what I want.
The frontend source does require the feature u pointed out.
I tried to find one could walk through the heirarchy. And
D does rock! now all frontend's DYNCAST can be deprecated!!

> davidl wrote:
>> umm , ur way rox either. but i don't know if the cast(derive)instance  
>> is  implemented as good as
>> (instance.classinfo is derive.classinfo)?
>>
>
> another issue:
>
> class A{}
> class B:A{}
> class C:B{}
>
> A a = new C;
> assert(cast(B)a !is null); // passes
>
> The strongest and fastest check might be to compare the vtbl pointers.  
> It will be a hack but it will be fast.



-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list