[Issue 21143] vtbl not accessible without typeid

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 11 20:14:30 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21143

--- Comment #3 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to Walter Bright from comment #1)
> It's actually not a __trait, is a pseudo-member:
> 
>   class C { ... }
>   void test(C c)
>   {
>     c.vptr // not the vtbl[] for C, but for the derived class that c is
>   }

My bad.

> What I can do is make:
> 
>     C.vptr give a pointer to the vtbl for class C
> 
> I don't think your use actually needs to know the number of entries in it?

I think the number of entries is important for applications that want to stick
their own type-specific info at the end of the table. Those could copy the vtbl
to the GC heap and append to it.

--


More information about the Digitalmars-d-bugs mailing list