Mistake #10 contains a race condition when another thread destroys the last shared_ptr to pIceman (Top Gun fan much?) between the call to !pMaverick-&gt;myWingMan.expired() and pMaverick-&gt;myWingMan.lock().<p>Just use:<p><pre><code>  if (auto p = pMaverick-&gt;myWingMan.lock())
    p-&gt;take_shower_with(pMaverick);
</code></pre>
See <a href="http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;weak_ptr&#x2F;lock" rel="nofollow">http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;memory&#x2F;weak_ptr&#x2F;lock</a>