Closed william-silversmith closed 1 year ago
I think this is probably not this library's fault. I experimented with another flat map implementation from tsl
and it exhibited the same issue. Closing this issue.
It looks like the issue was a poorly designed overloaded copy assignment operator in the edge_type
class. Sorry for bothering you.
Hi!
I was attempting to replace
std::unordered_map<uint64_t, edge_type>
(edge_type defined below) withrobin_hood::unordered_flat_map<uint64_t, edge_type>
. This caused my code to spinlock somehow, so I assumed it had something to do with invalidated iterators and hunted for a bug. I tried usingrobin_hood::unordered_node_map
and that gave correct results, though slower thanstd::unordered_map
so initially it seemed my hypothesis about iterators was correct.I spent some time tracing through the code and found that somehow data being inserted into the array was corrupted.
It turned out that the assertion statement was failing. I checked the output and added a few print statements to
emplace
:As you can see at the last emplacement, the retrieved value is (1,2) when the value inserted was (2,2) for a unique key.
My C++ knowledge isn't the strongest, could I perhaps be failing to hash
edge_type
correctly?The original
std::unordered_map
code in question can be found here:edge_type
)I also gave this a spin with the newer
ankerl::unordered_dense::map
and had the same issue of spinlocking, though I didn't attempt to debug it in fine detail like I did with robin_hood. I presume it's a similar issue and probably my fault.Thanks so much for such a helpful library!