xxxxxxxxxx
import std.stdio;
struct KeyRange {
size_t max;
bool opBinaryRight(string op : "in")(size_t v) {
return v >= 0 && v < max; // the < 0 never passes but meh clearer code
}
}
KeyRange keys(T)(T[] t) { return KeyRange(t.length); }
alias keys = object.keys; // also bring in the runtime library's keys for AA; this line lets both work together in the same module without name conflicts
void main()
{
int[] x = [0, 2];
int y = 1;
writeln(y in x.keys); // works!
writeln(y+5 in x.keys); // this too
}