How is std.traits.isInstanceOf supposed to work?

Dicebot public at dicebot.lv
Sun Nov 10 15:34:01 PST 2013


On Sunday, 10 November 2013 at 23:22:01 UTC, Tommi wrote:
> The documentation says:
>
> template isInstanceOf(alias S, T)
> ---------------------------
> Returns true if T is an instance of the template S.
>
> But, is isInstanceOf supposed to return true if T is a subtype 
> of an instance of the template S ? (but is not an instance of 
> the template S). Currently it does return true if T is a 
> struct, and doesn't if it's a class:

I'd say "works as expected". 'alias this` is not equivalent to 
inheritance, it allows to type to completely act as another. And 
`isInstanceOf` checks for strict matching. It will work with 
classes if `alias this` is used there.


More information about the Digitalmars-d mailing list