<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Does the weak_ptr need to be removed from the map &quot;instantly&quot; when it expires?<br>

Could you just clean up the expired weak_ptrs at some later point? &nbsp;For<br>
example, when an iterator is incremented it might remove all the weak_ptrs it<br>
encounters while it is trying to find the next live weak_ptr in the map.<br></blockquote><div><br>In my current usage scenario and implementation, I rely on values being removed &#39;instantly&#39;.<br><br>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 &#39;query&#39; time cost - I tend to see this weak_key_map as a lightweight construction if possible...<br>
<br></div></div>I also find that the &#39;instantly&#39; matches well the shared_ptr philosophy, but that&#39;s not very objective.<br>

