title: Is there an idiom like `if (Value * value = getValue())` when you branch on an expression of the retrieved value?
body: <p>I am often using the common </p>
  
  <pre><code>if (Value * value = getValue())
  {
      // do something with value
  }
  else
  {
      // handle lack of value
  }
  </code></pre>
  
  <p>Now, I also often do</p>
  
  <pre><code>QString error = someFunctionReturningAnErrorString(arg);
  if (!error.isEmpty())
  {
       // handle the error
  }
  // empty error means: no error
  </code></pre>
  
  <p>That's all fine but I would like the <code>error</code> variable to be scoped to the <code>if</code>-block. Is there a nice idiom for that? Obviously, I can just wrap the whole part inside another block. </p>
  
  <p>This, obviously, does not work:</p>
  
  <pre><code>if(QString error = someFunctionReturningAnErrorString(arg), !error.isEmpty())
  {
      // handle the error
  }
  // empty error means: no error
  </code></pre>
  
  <p>And unfortunately (but for good reasons) the <code>QString</code> cannot be converted to bool, so this does not work either:</p>
  
  <pre><code>if(QString error = someFunctionReturningAnErrorString(arg))
  {
      // handle the error
  }
  // empty error means: no error
  </code></pre>
  
  <p>Any suggestions?</p>