Ensuring template argument is descendant of class

Adam D. Ruppe destructionator at gmail.com
Thu Dec 12 13:53:18 PST 2013


On Thursday, 12 December 2013 at 21:51:14 UTC, Ross Hays wrote:
>         if (cast(Asset)T)

Try this instead:

    if(is(T : Asset))

the is thing checks types. You can do is(T == Asset) for the 
specific class, or is(T : Asset) which means it implicitly 
converts to it - in otherworts, if T is Asset or a child of Asset.


More information about the Digitalmars-d-learn mailing list