
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 12 December 2008 10:11 am, Nicolas Lelong wrote:
Is there some way that this can interface with boost::shared_ptr/weak_ptr better? weak_key_map
m; boost::shared_ptr<int> k(new int(1)); m.insert(std::make_pair(k,5)); assert(*m.find(k) == 5);
k.reset();
assert(m.empty());
I'd also like that, but in this approach, I can't figure how to hook into the key shared_ptr deleter to have access to a notification of the smart_ptr deletion. I think we can currently get the current deleter of a shared_ptr, but we can't change it to combine it with another deleter.
Does the weak_ptr need to be removed from the map "instantly" when it expires? Could you just clean up the expired weak_ptrs at some later point? For example, when an iterator is incremented it might remove all the weak_ptrs it encounters while it is trying to find the next live weak_ptr in the map. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFJQpbM5vihyNWuA4URAkukAKDH8yFJ2VBMsby254fnr0V2X8qrbwCg3cuJ 8PV44+yDWat+MG+zwGHiZ5E= =79yT -----END PGP SIGNATURE-----