In  it says at 5. that
For this reason, and for legacy reasons, an associative array
key is not allowed to define a specialized opCmp, but omit a
specialized opEquals. This restriction may be removed in future
versions of D.
I'm not completely sure what that means. Does "specialized" mean
"user-defined"? I just challenged the spec and found an error by
the way: . Apart from that, it compiles.
For 5. I used
int opCmp(const Key other) const
return this.id < other.id ? -1 : this.id == other.id ? 0
bool opEquals(ref const Key other) const @safe pure nothrow
return this.id == other.id;
size_t toHash() const @safe pure nothrow
as a key type. To me the part "is not allowed to define a
specialized opCmp" is clearly wrong, either a compiler bug or an
error in the spec.
Concerning opEquals and opCmp in general: Why isn't opEquals
lowered to opCmp returning 0 if not present?