isSignedInteger

Whether the given type is one of the built-in signed integer types, ignoring all qualifiers.

Signed Integer Types
byte
short
int
long

Note that this does not include implicit conversions or enum types. The type itself must be one of the built-in signed integer types.

See also: isFloatingPoint isInteger isNumeric isUnsignedInteger

enum isSignedInteger (
T
)

Examples

1 // Some types which are signed integer types.
2 static assert( isSignedInteger!byte);
3 static assert( isSignedInteger!short);
4 static assert( isSignedInteger!int);
5 static assert( isSignedInteger!long);
6 
7 static assert( isSignedInteger!(const byte));
8 static assert( isSignedInteger!(immutable short));
9 static assert( isSignedInteger!(inout int));
10 static assert( isSignedInteger!(shared int));
11 static assert( isSignedInteger!(const shared long));
12 
13 static assert( isSignedInteger!(typeof(42)));
14 static assert( isSignedInteger!(typeof(1234567890L)));
15 
16 int i;
17 static assert( isSignedInteger!(typeof(i)));
18 
19 // Some types which aren't signed integer types.
20 static assert(!isSignedInteger!ubyte);
21 static assert(!isSignedInteger!ushort);
22 static assert(!isSignedInteger!uint);
23 static assert(!isSignedInteger!ulong);
24 
25 static assert(!isSignedInteger!bool);
26 static assert(!isSignedInteger!char);
27 static assert(!isSignedInteger!wchar);
28 static assert(!isSignedInteger!dchar);
29 static assert(!isSignedInteger!(int[]));
30 static assert(!isSignedInteger!(ubyte[4]));
31 static assert(!isSignedInteger!(int*));
32 static assert(!isSignedInteger!double);
33 static assert(!isSignedInteger!string);
34 
35 static struct S
36 {
37     int i;
38 }
39 static assert(!isSignedInteger!S);
40 
41 // The struct itself isn't considered a signed integer,
42 // but its member variable is when checked directly.
43 static assert( isSignedInteger!(typeof(S.i)));
44 
45 enum E : int
46 {
47     a = 42
48 }
49 
50 // Enums do not count.
51 static assert(!isSignedInteger!E);
52 
53 static struct AliasThis
54 {
55     int i;
56     alias this = i;
57 }
58 
59 // Other implicit conversions do not count.
60 static assert(!isSignedInteger!AliasThis);

Meta