nullptr and checking if a pointer points to a valid object
<p>In a couple of my older code projects when i had never heard of smart pointers, whenever i needed to check whether the pointer still pointed to a valid object, i would always do something like this...</p>

<pre><code>object * meh = new object;
if(meh) 
    meh-&gt;member;
</code></pre>

<p>or when i needed to delete the object safely, something like this</p>

<pre><code>if(meh)
{
    delete meh;
    meh = 0;
}
</code></pre>

<p>well, now i have learned about the problems that can arise from using objects and pointers in bollean expressions both with literal numbers, the hard way :\ . And now i've also learned of the not so new but pretty cool feature of c++, the nullptr keyword. But now i'm curious.</p>

<p>I've already gone through and revised most of my code so that, for example, when deleting objects i now write</p>

<pre><code>if(meh)
{
    delete meh;
    meh = nullptr;
}
</code></pre>

<p>but now i'm wondering about the boolean. when you pass just say an int into an if statement like this,</p>

<pre><code>int meh;
if(meh)
</code></pre>

<p>then it implicitly checks for zero without you needing to write it.</p>

<pre><code>if(meh == 0) // does the exact same check
</code></pre>

<p>but now, will c++ do the same for pointers? if pass in a char * like this to an if statement?</p>

<pre><code>char * meh;
if(meh)
</code></pre>

<p>then will it implicitly compare it with nullptr? Because of how long I have been writing these ifs like this, it is second nature at this point to check if the pointers valid before using by typing if(object *) and then calling it's members. If this is not the functionality why not? too difficult to implement? would solve some problems by removing yet another tiny way you could mess up your code.</p>
