How can I test at compile time whether T is an instance of an interface ?
wjoe
invalid at example.com
Wed Sep 23 18:59:08 UTC 2020
On Wednesday, 23 September 2020 at 18:50:28 UTC, H. S. Teoh wrote:
> Try this:
>
> interface I {}
> class C : I {}
> class D {}
> struct S {}
>
> pragma(msg, is(C : I)); // true
> pragma(msg, is(D : I)); // false
> pragma(msg, is(S : I)); // false
>
> So probably what you want is something like this:
>
> void register(C, ARGS...)(ARGS args)
> if (behavesLikeFoo!C || is(C : IFoo))
> ...
>
>
> T
Yes, that's it. Thanks :)
More information about the Digitalmars-d-learn
mailing list