Boost logo

Boost Users :

From: johneddy101_at_[hidden]
Date: 2006-12-19 14:49:17

I'm running into a problem while using hashed indices in a container storing shared_ptr's. The problem is occuring in the hashed_index::erase(key) method in both the 1_33_1 release and the CVS head version. This is what the problem seems to be:
It is possible that the call to erase (or final_erase_) occurring within the do loop causes destruction of the passed in key object. The key object (k) is then used in a comparison in the while portion of the loop (y!=x&&eq(k, key(…))). The default predicate uses == in this comparison but one of the items (the left hand side) will have already been destroyed.
I'm afraid that I don't know a good solution to this problem. I see from your commit logs on this file that there is a problem using something like is done in the ordered_indices (deleting equal_range items) whereby it increases the complexity. I can see from the implementation of equal_range on hashed indices that this is a potentially expensive operation for non-unique collections with many collisions. However, since speed is a secondary consideration for me, this is the solution I'm using for now.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at