Can you use RTTI to determine a union member?

0ffh spam at frankhirsch.net
Tue Oct 16 13:27:09 PDT 2007


Frits van Bommel wrote:
> Christian Kamm wrote:
>> If A, B, C are classes, you could also check with
>>
>> u.a.classinfo is A.classinfo
>> u.a.classinfo is B.classinfo
>> u.a.classinfo is C.classinfo.
> 
> Only if the union never stores references to subclasses.

Righto, AFAIK; in that case one might consider to have all
classes implement an interface with a member that holds
an identifier for the class. Or use, as has been mentioned
already, the classical variant of adding the type info
in a struct wrapped around the union.

Regards, Frank



More information about the Digitalmars-d mailing list