This works only for c 17. Is there a way to convert this to c 14?
if (auto user = static_cast<CUser*>(pMover); user && !user->IsRecordBookOptIn())
return;
CodePudding user response:
You have to split the if into 2 statements.
In order to limit the scope of user to the if statement, you can enclose it with {...}:
{
auto user = static_cast<CUser*>(pMover);
if (user && !user->IsRecordBookOptIn())
return;
}
CodePudding user response:
In this case, it's simple:
if (pMover && static_cast<CUser*>(pMover)->IsRecordBookOptIn()) return;
static_cast<CUser*>(pMover) is nullptr if and only if pMover is nullptr. And in that case, && doesn't evaluate the right-hand side.
