diff --git a/programs/Hadrons/Environment.hpp b/programs/Hadrons/Environment.hpp index 7f55308a..65f870ee 100644 --- a/programs/Hadrons/Environment.hpp +++ b/programs/Hadrons/Environment.hpp @@ -149,11 +149,11 @@ T * Environment::get(const std::string name) const { if (hasLattice(name)) { - try + if (auto pt = dynamic_cast(lattice_.at(name).get())) { - return dynamic_cast(lattice_.at(name).get()); + return pt; } - catch (std::bad_cast &) + else { HADRON_ERROR("object '" + name + "' does not have type " + typeid(T *).name() + "(object type: "