[Issue 17206] [Tracking] Check that opEquals and toHash are both defined or neither are defined
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Jul  2 19:11:17 UTC 2018
    
    
  
https://issues.dlang.org/show_bug.cgi?id=17206
Nathan S. <n8sh.secondary at hotmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |n8sh.secondary at hotmail.com
--- Comment #2 from Nathan S. <n8sh.secondary at hotmail.com> ---
Half of this is wrong.  For a type to be usable as a key in an associative
array it must be true that "a == b" implies "a.toHash() == b.toHash()", so when
there is a non-default `==` there should also be a custom `toHash` to maintain
this property. But the reverse is not true: defining a non-default `toHash`
does not require a custom `opEquals`, because the default `==` is already the
strictest possible condition that satisfies "a == a" (since structs can be
relocated).
--
    
    
More information about the Digitalmars-d-bugs
mailing list