Converting a type to a char
Thomas Gregory
charles.gregory940 at topper.wku.edu
Fri Jan 25 15:53:10 UTC 2019
I would like to check that a char (unknown at compile time)
matches a particular type but I would like to do so without if
statements or a hash map as I would like it to be as fast as
possible.
Ideally I would choose something like this:
enum typeIndex{
byte = 0,
ubyte,
short,
ushort,
int,
uint
}
char[6] typechars="cCsSiI";
bool check(T)(char c){
return typechars[typeIndex(typeof(T))]==c;
}
Though I know this is implementation is not remotely correct D.
More information about the Digitalmars-d-learn
mailing list