Skip to content

Commit

Permalink
Simplified code
Browse files Browse the repository at this point in the history
A const_cast that was apparently a residual of older implementations
  • Loading branch information
GiovanniBussi committed Jan 22, 2024
1 parent ba9a138 commit 00b63d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tools/SwitchingFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ void SwitchingFunction::set(const std::string & definition,std::string& errormsg
// e.g. func=0*x
lepton_ref[t]=nullptr;
} else if(vars.size()==1 && found_x) {
lepton_ref[t]=&const_cast<lepton::CompiledExpression*>(&expression[t])->getVariableReference("x");
lepton_ref[t]=&expression[t].getVariableReference("x");
} else if(vars.size()==1 && found_x2) {
lepton_ref[t]=&const_cast<lepton::CompiledExpression*>(&expression[t])->getVariableReference("x2");
lepton_ref[t]=&expression[t].getVariableReference("x2");
leptonx2=true;
} else if(vars.size()==2 && found_x && found_x2) {
plumed_error() << "Cannot use simultaneously x and x2 argument in switching function: "<<func;
Expand All @@ -296,7 +296,7 @@ void SwitchingFunction::set(const std::string & definition,std::string& errormsg
lepton_ref_deriv.resize(expression_deriv.size());
for(unsigned t=0; t<lepton_ref_deriv.size(); t++) {
try {
lepton_ref_deriv[t]=&const_cast<lepton::CompiledExpression*>(&expression_deriv[t])->getVariableReference(arg);
lepton_ref_deriv[t]=&expression_deriv[t].getVariableReference(arg);
} catch(const PLMD::lepton::Exception& exc) {
// this is necessary since in some cases lepton things a variable is not present even though it is present
// e.g. func=3*x
Expand Down

0 comments on commit 00b63d5

Please sign in to comment.