-
-
Notifications
You must be signed in to change notification settings - Fork 147
it = map.erase(it) potentially passes object twice #42
Comments
The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos. |
@ktprime, this is not about the end() iterator, this is about the backward-shift-deletion which shuffles elements around when erasing an element. See Tessil/robin-map#20 |
Any progress on this or any workaround? If not, is there any alternative unordered_map that you recommend? Thanks. |
Unfortunately, not yet. This is an edge case that's very difficult to solve in an efficient way. If you need the standard behavior, switch to |
I think of all the possible solutions to this problem, the least bad is to ditch the wrap around and add a buffer to the end of the data array. Since mInfo is limited, The size of that buffer can also be very limited: |
I've finally fixed the issue. As explained above, I've added a buffer for the overflow, so there's no wrap around any more. The added benefit is that a lot less |
It seems @jcageman has stumbled uppon an issue that probably all robin-hood map with backward shift deletion have (see #18). Here is a simple reproducer
Insert two elements, where both hash to the last bucket of the map. One entry will be the last one of the map, the other one will wrap around and use the first bucket.
Also see Tessil/robin-map#20
The text was updated successfully, but these errors were encountered: