use dynamic cast instead of c-style cast when casting from base type to derived class

This commit is contained in:
Axel Kohlmeyer
2022-04-10 18:18:06 -04:00
parent 39b316729b
commit 200b4f13c7
262 changed files with 669 additions and 676 deletions

View File

@ -37,7 +37,7 @@ ComputeBond::ComputeBond(LAMMPS *lmp, int narg, char **arg) :
// check if bond style hybrid exists
bond = (BondHybrid *) force->bond_match("hybrid");
bond = dynamic_cast<BondHybrid *>( force->bond_match("hybrid"));
if (!bond)
error->all(FLERR,"Bond style for compute bond command is not hybrid");
size_vector = nsub = bond->nstyles;
@ -60,7 +60,7 @@ void ComputeBond::init()
{
// recheck bond style in case it has been changed
bond = (BondHybrid *) force->bond_match("hybrid");
bond = dynamic_cast<BondHybrid *>( force->bond_match("hybrid"));
if (!bond)
error->all(FLERR,"Bond style for compute bond command is not hybrid");
if (bond->nstyles != nsub)