From 00b63d594487f4445e7d6748ef65c246c7ce3173 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi Date: Mon, 22 Jan 2024 14:39:51 +0100 Subject: [PATCH] Simplified code A const_cast that was apparently a residual of older implementations --- src/tools/SwitchingFunction.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/SwitchingFunction.cpp b/src/tools/SwitchingFunction.cpp index caa4874cba..d4d6f910c6 100644 --- a/src/tools/SwitchingFunction.cpp +++ b/src/tools/SwitchingFunction.cpp @@ -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(&expression[t])->getVariableReference("x"); + lepton_ref[t]=&expression[t].getVariableReference("x"); } else if(vars.size()==1 && found_x2) { - lepton_ref[t]=&const_cast(&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: "<(&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