How can I match every instance of a template type (struct)?
Salih Dincer
salihdb at hotmail.com
Tue Jul 12 18:51:28 UTC 2022
On Tuesday, 12 July 2022 at 15:30:03 UTC, Ali Çehreli wrote:
>
> An alternative:
> https://dlang.org/phobos/std_traits.html#isInstanceOf
>
This is a really good alternative. Because I used to have to
write longer. Thanks, the LOG thing is better now:
```d
struct LOG(T...) {
T[0] id;
T[1] data;
}
void main()
{
auto obj = //make_test(20);/*
make_test('T');//*/
alias typ = //typeof(obj);/*
LOG!(int, char);//*/
"Type: ".write;
if(isInstanceOf!(LOG, typ)/*
is(typ : Template!Args,
alias Template, Args...)//*/
) "LOG".writeln;
}
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list