Pseudo member aliases
Deokjae Lee
asitdepends at gmail.com
Thu Aug 12 02:05:53 PDT 2010
void func(K,V)(in K[V] x) {
}
void main(string[] args) {
auto x = [1:"1", 2:"2"];
x.func();
}
Ok, the function func can be called like a member function of a type K[V].
Is there any way to do similar work on alias?
Actually I'd like to define aliases ValueType and KeyType on associative
arrays and plain arrays, so that they are like member aliases of the
array types.
If it is possible, code like the following would be compiled using them.
writeln(typeid((string[]).KeyType))); //print "int"
writeln(typeid((string[]).ValueType))); //print "immutable(char)[]"
auto x = [1:"hello", 2:"world"];
writeln(typeid(x.ValueType));//print "immutable(char)[]"
More information about the Digitalmars-d-learn
mailing list