title: Can I write this if statement with a variable declaration on one line?
body: <p>I was wondering if there was a way to put this on one line?</p>
  
  <pre><code>if (auto r = getGlobalObjectByName(word)) r-&gt;doSomething; // This works fine
  
  if (!auto r = getGlobalObjectByName(word)) r-&gt;doSomething; // Says "expected an expression"
  
  if (auto r = getGlobalObjectByName(word) == false) r-&gt;doSomething; // Also doesn't work.
  </code></pre>
  
  <p>I also tried surrounding it with extra brackets, but that doesn't seem to work. I find this really convenient doing it on one line.</p>