title: Is "delete p; p = NULL(nullptr);" an antipattern?
body: <p>Searching something on SO, I stumbled across <a href="https://stackoverflow.com/questions/2828841/what-is-purpose-of-a-this-pointer-in-c">this question</a> and one of the comments to the most voted answer (the fifth comment to that most voted answer) suggests that <code>delete p; p = NULL;</code> is an <em>antipattern</em>. I must confess that I happen to use it quite often paring it sometimes\most of the times with the check <code>if (NULL != p)</code>. <a href="http://www2.research.att.com/~bs/bs_faq2.html#delete-zero" rel="nofollow noreferrer">The Man</a> himself seems to suggest it (please see the <code>destroy()</code> function example) so I'm really confused to why it might be such a dreaded thing to be considered an <em>antipattern</em>. I use it for the following reasons:</p>
  
  <ul>
  <li>when I'm releasing a resource I also want to kind of invalidate it for further usage and NULL is the right tool to say a pointer is invalid</li>
  <li>I don't want to leave behind dangling pointers</li>
  <li>I want to avoid double\multiple free bugs - deleting a NULL pointer is like a nop but deleting a dangling pointer is like "shooting yourself in the foot"</li>
  </ul>
  
  <p>Please note that I'm not asking the question in the context of the <em>"this"</em> pointer and let's assume we don't live in a perfect C++ world and that legacy code does exist and it has to be maintained, so please do not suggest any kind of smart pointer :).</p>