{ int val; if (getFoo(&val)) { ... }}
{ int val; if (getFoo(&val)) { } printf("%d", val); }
Also, this was one example. There are plenty of other examples.
But i agree the C++ if(init;cond) thing was new to me.
if (Foo* f = GetPtr(); f->HasValue()) {} // wrong; f can be null
if (Foo* f = GetPtr(); f && f->HasValue()){}
if (Foo* f = GetPtr()) { f->DoTheThing(); // this is perfectly safe. }
Also, this was one example. There are plenty of other examples.