Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 22, 2019 How to write __traits(isSame, T, int) use another way | ||||
---|---|---|---|---|
| ||||
Hi: I think the __traits(isSame, T, int) syntax is too uglily, Is where an other way rewrite it. like this isSameType!(T,int) |
August 22, 2019 Re: How to write __traits(isSame, T, int) use another way | ||||
---|---|---|---|---|
| ||||
Posted in reply to lili | On Thursday, 22 August 2019 at 16:54:56 UTC, lili wrote:
> I think the __traits(isSame, T, int) syntax is too uglily,
> Is where an other way rewrite it. like this isSameType!(T,int)
For types you can (and often should) just use
is(T == int)
the isSame thing is more about comparing aliases rather than types.
|
August 22, 2019 Re: How to write __traits(isSame, T, int) use another way | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Thursday, 22 August 2019 at 17:01:09 UTC, Adam D. Ruppe wrote:
> On Thursday, 22 August 2019 at 16:54:56 UTC, lili wrote:
>> I think the __traits(isSame, T, int) syntax is too uglily,
>> Is where an other way rewrite it. like this isSameType!(T,int)
>
> For types you can (and often should) just use
>
> is(T == int)
>
>
> the isSame thing is more about comparing aliases rather than types.
Thanks alot, How to get a variable's type?
void println(A...)(A a)
{
//TODO static if type
foreach(c ; a) {
static if (??(c) == int) //How to get c's type???
}
}
|
Copyright © 1999-2021 by the D Language Foundation