MyStruct(T) { T[T] attributes; // .... public auto getAttribute(T attr) { if (!(attr in attributes)) { return null; // Doesn't work for numbers! } return attributes[attr]; } }
void main() { auto myStr = MyStruct!int(0); // Error }
MyStruct(T) { T[T] attributes; // .... public auto getAttribute(T attr) { if (!(attr in attributes)) { return null; // Doesn't work for numbers! } return attributes[attr]; } }
void main() { auto myStr = MyStruct!int(0); // Error }