https://issues.dlang.org/show_bug.cgi?id=17206
Steven Schveighoffer <schvei...@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schvei...@yahoo.com --- Comment #3 from Steven Schveighoffer <schvei...@yahoo.com> --- No, toHash doesn't necessarily have to follow the semantics of default opEquals. Example: struct S1(bool customTohash) { string s; static if(customTohash) { size_t toHash() const { return cast(size_t)s.ptr + s.length; // use string identity } /+ really should define this bool opEquals(const(S1) other) const { return other.s is s; } +/ } } void main() { bool[S1!false] aa1; aa1[S1!false("hello".idup)] = true; aa1[S1!false("hello".idup)] = true; assert(aa1.length == 1); bool[S1!true] aa2; aa2[S1!true("hello".idup)] = true; aa2[S1!true("hello".idup)] = true; assert(aa2.length == 1); // fails } --