typeid() broken for interfaces?

Walter Bright newshound2 at digitalmars.com
Sun Dec 2 21:58:26 PST 2012


On 12/3/2012 4:43 PM, Gor Gyolchanyan wrote:
> Wouldn't it be better to return the class's typeinfo if it is a class
> and the interface's typeinfo if it isn't? The interface would then
> return the most derived typeinfo that it knows of. I think, just because
> the interface can be something other then a class object, doesn't mean
> it should be treated as though it will never be a class object.

A particular interface can be implemented by many different class types, 
or by something that isn't even a class, so returning a typeid that's a 
class typeid would make it impossible to compare one with another.



More information about the Digitalmars-d mailing list