title: Operator overload for object to be used in conditional statement
body: <p>How can I pass my object to an <code>if</code> statement and check if it is <code>true</code> or <code>false</code></p>
  <p>example:</p>
  <pre><code>struct A {
     int num;
  
     operator bool good() const {return num &gt; 0;}
  }
  
  A a{1}; if(a) { /* it's all good man! */ }
  </code></pre>
  <p>I got inspired by <code>std::function</code> where you can <a href="https://en.cppreference.com/w/cpp/utility/functional/function/operator_bool" rel="nofollow noreferrer">pass it into a if statement</a> and it will return true if function pointer is set:</p>
  <pre><code>void checkFunc( std::function&lt;void()&gt; const &amp;func )
  {
      // Use operator bool to determine if callable target is available.
      if( func )  
      {
          std::cout &lt;&lt; &quot;Function is not empty! Calling function.\n&quot;;
          func();
      }
      else
      {
          std::cout &lt;&lt; &quot;Function is empty. Nothing to do.\n&quot;;
      }
  }
  </code></pre>