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->UserState())
return;
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->UserState())
return;
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->UserState())
return;
}
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.