Indexing an associative array with a list of types
Doctor J
nobody at nowhere.com
Sat Apr 11 14:44:36 PDT 2009
I'd like to make a compile-time constant associative array mapping a list of types to an integer:
int[??] typemap;
typemap[(int,float)] = 1;
typemap[(long,double)] = 2;
...
int t = typemap[(int,float)];
I tried playing with std.typetuple but no luck. I can get halfway there with a function template, but then I can't iterate over the keys or values. Is there a way to do something like this in D? More generally, is there a way to store a type in a variable?
Thanks.
More information about the Digitalmars-d-learn
mailing list