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. }