title: Is !! a safe way to convert to bool in C++?
body: <p><em>[This question is related to but not the same as <a href="https://stackoverflow.com/questions/206564/what-is-the-performance-implication-of-converting-to-bool-in-c">this one</a>.]</em></p>
  
  <p>If I try to use values of certain types as boolean expressions, I get a warning.  Rather than suppress the warning, I sometimes use the ternary operator (<code>?:</code>) to convert to a bool.  Using two not operators (<code>!!</code>) seems to do the same thing.</p>
  
  <p>Here's what I mean:</p>
  
  <pre><code>typedef long T;       // similar warning with void * or double
  T t = 0;
  bool b = t;           // performance warning: forcing 'long' value to 'bool'
  b = t ? true : false; // ok
  b = !!t;              // any different?
  </code></pre>
  
  <p>So, does the double-not technique really do the same thing?  Is it any more or less safe than the ternary technique?  Is this technique equally safe with non-integral types (e.g., with <code>void *</code> or <code>double</code> for <code>T</code>)?</p>
  
  <p>I'm not asking if <code>!!t</code> is good style.  I am asking if it is semantically different than <code>t ? true : false</code>.</p>