diff --git a/src/MISC/fix_srp.cpp b/src/MISC/fix_srp.cpp index f4f9abc629..e82e98448f 100644 --- a/src/MISC/fix_srp.cpp +++ b/src/MISC/fix_srp.cpp @@ -116,7 +116,7 @@ void FixSRP::init() // because this fix's pre_exchange() creates per-atom data structure // that data must be current for atom migration to carry it along - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (ifix == this) break; if (ifix->pre_exchange_migrate) error->all(FLERR,"Fix {} comes after a fix which migrates atoms in pre_exchange", style); diff --git a/src/MISC/pair_srp_react.cpp b/src/MISC/pair_srp_react.cpp index 25975c7fb0..4a3f260fe0 100644 --- a/src/MISC/pair_srp_react.cpp +++ b/src/MISC/pair_srp_react.cpp @@ -72,7 +72,7 @@ PairSRPREACT::PairSRPREACT(LAMMPS *lmp) : // pair srp/react has its own fix, hence delete fix srp instance // created in the constructor of pair srp - for (auto ifix : modify->get_fix_by_style("SRP")) + for (auto &ifix : modify->get_fix_by_style("SRP")) modify->delete_fix(ifix->id); // similar to fix SRP, create fix SRP REACT instance here with unique fix id diff --git a/src/PLUGIN/plugin.cpp b/src/PLUGIN/plugin.cpp index 5451cd31e2..97c3b36cce 100644 --- a/src/PLUGIN/plugin.cpp +++ b/src/PLUGIN/plugin.cpp @@ -369,7 +369,7 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) // must delete all compute instances using this compute style - for (auto icompute : lmp->modify->get_compute_by_style(name)) + for (auto &icompute : lmp->modify->get_compute_by_style(name)) lmp->modify->delete_compute(icompute->id); } else if (pstyle == "fix") { @@ -380,7 +380,7 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) // must delete all fix instances using this fix style - for (auto ifix : lmp->modify->get_fix_by_style(name)) lmp->modify->delete_fix(ifix->id); + for (auto &ifix : lmp->modify->get_fix_by_style(name)) lmp->modify->delete_fix(ifix->id); } else if (pstyle == "region") { @@ -388,7 +388,7 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) auto found = region_map->find(name); if (found != region_map->end()) region_map->erase(name); - for (auto iregion : lmp->domain->get_region_by_style(name)) lmp->domain->delete_region(iregion); + for (auto &iregion : lmp->domain->get_region_by_style(name)) lmp->domain->delete_region(iregion); } else if (pstyle == "command") { diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp index b2b0366b9e..312208f4d9 100644 --- a/src/POEMS/fix_poems.cpp +++ b/src/POEMS/fix_poems.cpp @@ -354,7 +354,7 @@ void FixPOEMS::init() if (earlyflag) { bool pflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (utils::strmatch(ifix->style, "^poems")) pflag = true; if (pflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag) if (comm->me == 0) @@ -365,7 +365,7 @@ void FixPOEMS::init() // error if npt,nph fix comes before rigid fix bool pflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (!pflag && utils::strmatch(ifix->style, "np[th]")) error->all(FLERR, "POEMS fix must come before NPT/NPH fix"); if (utils::strmatch(ifix->style, "^poems")) pflag = true; diff --git a/src/REPLICA/hyper.cpp b/src/REPLICA/hyper.cpp index f13711f213..c2e968e41b 100644 --- a/src/REPLICA/hyper.cpp +++ b/src/REPLICA/hyper.cpp @@ -152,10 +152,10 @@ void Hyper::command(int narg, char **arg) // cannot use hyper with time-dependent fixes or regions - for (auto ifix : modify->get_fix_list()) + for (auto &ifix : modify->get_fix_list()) if (ifix->time_depend) error->all(FLERR,"Cannot use hyper with a time-dependent fix defined"); - for (auto reg : domain->get_region_list()) + for (auto ® : domain->get_region_list()) if (reg->dynamic_check()) error->all(FLERR,"Cannot use hyper with a time-dependent region defined"); @@ -177,7 +177,7 @@ void Hyper::command(int narg, char **arg) fix_event->store_state_quench(); quench(1); - if (dumpflag) for (auto idump : dumplist) idump->write(); + if (dumpflag) for (auto &idump : dumplist) idump->write(); fix_event->store_event(); if (hyperenable) fix_hyper->build_bond_list(0); fix_event->restore_state_quench(); @@ -206,7 +206,7 @@ void Hyper::command(int narg, char **arg) nevent++; nevent_atoms += ecount; - if (dumpflag) for (auto idump : dumplist) idump->write(); + if (dumpflag) for (auto &idump : dumplist) idump->write(); fix_event->store_event(); if (hyperenable) fix_hyper->build_bond_list(ecount); diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 79d09080ec..a658dba853 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -229,10 +229,10 @@ void PRD::command(int narg, char **arg) // cannot use PRD with time-dependent fixes or regions - for (auto ifix : modify->get_fix_list()) + for (auto &ifix : modify->get_fix_list()) if (ifix->time_depend) error->all(FLERR,"Cannot use PRD with a time-dependent fix defined"); - for (auto reg : domain->get_region_list()) + for (auto ® : domain->get_region_list()) if (reg->dynamic_check()) error->all(FLERR,"Cannot use PRD with a time-dependent region defined"); diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index f21d46d576..eecd59cfa0 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -684,13 +684,13 @@ void FixRigid::init() // if earlyflag, warn if any post-force fixes come after a rigid fix int count = 0; - for (auto ifix : modify->get_fix_list()) + for (auto &ifix : modify->get_fix_list()) if (ifix->rigid_flag) count++; if (count > 1 && me == 0) error->warning(FLERR,"More than one fix rigid"); if (earlyflag) { bool rflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (ifix->rigid_flag) rflag = true; if ((comm->me == 0) && rflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag) error->warning(FLERR,"Fix {} with ID {} alters forces after fix rigid", @@ -713,7 +713,7 @@ void FixRigid::init() // error if a fix changing the box comes before rigid fix bool boxflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (boxflag && utils::strmatch(ifix->style,"^rigid")) error->all(FLERR,"Rigid fixes must come before any box changing fix"); if (ifix->box_change) boxflag = true; diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index ec3e58d5f5..2eb3c1a63c 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -529,13 +529,13 @@ void FixRigidSmall::init() // if earlyflag, warn if any post-force fixes come after a rigid fix int count = 0; - for (auto ifix : modify->get_fix_list()) + for (auto &ifix : modify->get_fix_list()) if (ifix->rigid_flag) count++; if (count > 1 && me == 0) error->warning(FLERR,"More than one fix rigid"); if (earlyflag) { bool rflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (ifix->rigid_flag) rflag = true; if ((comm->me == 0) && rflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag) error->warning(FLERR,"Fix {} with ID {} alters forces after fix rigid/small", @@ -558,7 +558,7 @@ void FixRigidSmall::init() // error if a fix changing the box comes before rigid fix bool boxflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (boxflag && utils::strmatch(ifix->style,"^rigid")) error->all(FLERR,"Rigid fixes must come before any box changing fix"); if (ifix->box_change) boxflag = true; diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 6673472458..1ff61c8856 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -360,7 +360,7 @@ void FixShake::init() // error if a fix changing the box comes before shake fix bool boxflag = false; - for (auto ifix : modify->get_fix_list()) { + for (auto &ifix : modify->get_fix_list()) { if (boxflag && utils::strmatch(ifix->style,pattern)) error->all(FLERR,"Fix {} must come before any box changing fix", style); if (ifix->box_change) boxflag = true; diff --git a/src/domain.cpp b/src/domain.cpp index 48631a0899..c3dacc0201 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -125,7 +125,7 @@ Domain::~Domain() { if (copymode) return; - for (auto reg : regions) delete reg; + for (auto ® : regions) delete reg; regions.clear(); delete lattice; delete region_map; @@ -190,7 +190,7 @@ void Domain::init() // region inits - for (auto reg : regions) reg->init(); + for (auto ® : regions) reg->init(); } /* ---------------------------------------------------------------------- diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp index de24d9d652..bc6e61a69e 100644 --- a/src/fix_deform.cpp +++ b/src/fix_deform.cpp @@ -882,7 +882,7 @@ void FixDeform::end_of_step() if (mask[i] & groupbit) domain->x2lamda(x[i],x[i]); - for (auto ifix : rfix) + for (auto &ifix : rfix) ifix->deform(0); } @@ -921,7 +921,7 @@ void FixDeform::end_of_step() if (mask[i] & groupbit) domain->lamda2x(x[i],x[i]); - for (auto ifix : rfix) + for (auto &ifix : rfix) ifix->deform(1); } diff --git a/src/utils.cpp b/src/utils.cpp index 9e6aa8e5d1..6483997dc9 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1129,7 +1129,7 @@ bool utils::is_integer(const std::string &str) { if (str.empty()) return false; - for (auto c : str) { + for (const auto &c : str) { if (isdigit(c) || c == '-' || c == '+') continue; return false; } @@ -1144,7 +1144,7 @@ bool utils::is_double(const std::string &str) { if (str.empty()) return false; - for (auto c : str) { + for (const auto &c : str) { if (isdigit(c)) continue; if (c == '-' || c == '+' || c == '.') continue; if (c == 'e' || c == 'E') continue; @@ -1161,7 +1161,7 @@ bool utils::is_id(const std::string &str) { if (str.empty()) return false; - for (auto c : str) { + for (const auto &c : str) { if (isalnum(c) || (c == '_')) continue; return false; } @@ -1178,7 +1178,7 @@ int utils::is_type(const std::string &str) bool numeric = true; int nstar = 0; - for (auto c : str) { + for (const auto &c : str) { if (isdigit(c)) continue; if (c == '*') { ++nstar;