Re: Strange behavior of opEquals for structs

2019-06-19 Thread harfel via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 17:15:31 UTC, Ali Çehreli wrote: On 06/19/2019 08:28 AM, harfel wrote: You need to define toHash() member function as well: https://dlang.org/spec/hash-map.html#using_struct_as_key Ali Thanks Ali, This fixed my problem, of course. Amazing that such a beginner

Re: Strange behavior of opEquals for structs

2019-06-19 Thread Ali Çehreli via Digitalmars-d-learn
On 06/19/2019 08:28 AM, harfel wrote: Everything works nicely if I compare the structs directly. Yet when they are used as keys in an associative array, the code throws an exception that I do not understand. You need to define toHash() member function as well: https://dlang.org/spec/hash-m

Strange behavior of opEquals for structs

2019-06-19 Thread harfel via Digitalmars-d-learn
I am trying to overload opEquals for a struct. The struct will hold class objects that define their own opEquals so the default bitwise comparison is not good for me. Everything works nicely if I compare the structs directly. Yet when they are used as keys in an associative array, the code thro