I want check, if the type is byte/short/int/long
or it is ubyte/ushort/uint/ulong
. The first idea was to use construction is(T1:T2)
, but is(ulong:long)==is(long:ulong)==true
, so it is not the way.
Now I'm using something like is(T:long) && (cast(T)(-1)<cast(T)(1))
, but this code seems ugly to me.
So is there more elegant logic statement returning true
only if the type is unsigned?
There is a template in std.traits
that does what you want:
http://dlang.org/phobos/std_traits.html#.isUnsigned
Use it like:
if(isUnsigned!T1) {
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With