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.

In my current usage scenario and implementation, I rely on values being removed 'instantly'.

The thing is that I never iterate these maps, I only query values associated to keys ; so in this case, a cleanup could be triggered, but it would increase the 'query' time cost - I tend to see this weak_key_map as a lightweight construction if possible...

I also find that the 'instantly' matches well the shared_ptr philosophy, but that's not very objective.