Why can't variables defined in a conditional be constructed with arguments?
<p>The question is simple.  Why does this compile:</p>

<pre><code>bool b(true);
if (b) { /* */ }
</code></pre>

<p>And this compile:</p>

<pre><code>if (bool b = true) { /* */ }
</code></pre>

<p>But not this:</p>

<pre><code>if (bool b(true)) { /* */ }
</code></pre>

<p>In my real code, I need to construct an object and test it, while also having it destroyed when the if-block ends.  Basically, I'm looking for something like this:</p>

<pre><code>{
    Dingus dingus(another_dingus);
    if (dingus) {
        // ...
    }
}
</code></pre>

<p>Of course, this would work:</p>

<pre><code>if (Dingus dingus = another_dingus) { /* */ }
</code></pre>

<p>But then I'm constructing a <code>Dingus</code> and calling <code>operator=</code> on it.  It seems logical to me that I would be able to construct the object using whatever constructor I please.</p>

<p>But I'm baffled why this isn't grammatically correct.  I've tested with G++ and MSVC++ and they both complain about this construct, so I'm sure it's part of the spec but I'm curious as to the reasoning for this and what non-ugly workarounds there may be.</p>
