Polymorphism in regular variadic function
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Dec 5 16:45:26 PST 2006
"Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message
news:el52bq$2dcb$1 at digitaldaemon.com...
> Thanks Jarrett,
> This TypeInfo_Class thing seems to be undocumented.
>
> Incidentally it's a piece of cake with a variadic template, I just wanted
> to see try it with a regular function first before going all templatey.
>
> I haven't tried your code, but it seems like your cast to Object in the
> second suggestion is not going to be safe if the thing really isn't an
> Object. The following cast to Foo will try to do some vtable stuff I
> guess, and that could result in a bad memory access, no?
Hmm.. I don't think it should. TypeInfo_Class is, well, the typeinfo for a
class, which all derive from Object, so getting the param as an Object
shouldn't be a problem, should it?
..oh crap. Interfaces also have a TypeInfo_Class. :S And since they
aren't _required_ to be castable to object (i.e. COM interfaces)..
Yeah, the other way is necessary.
More information about the Digitalmars-d-learn
mailing list