diff --git a/src/EquationTags.hh b/src/EquationTags.hh index 34277baef41c7a09123cd8fbc9a9c1a5677dafdb..7db769b39ac0f5996aa34e2b3ac993af170fd767 100644 --- a/src/EquationTags.hh +++ b/src/EquationTags.hh @@ -20,12 +20,13 @@ #ifndef _EQUATION_TAGS_HH #define _EQUATION_TAGS_HH -using namespace std; - +#include <iostream> #include <map> #include <set> #include <string> +using namespace std; + class EquationTags { private: diff --git a/src/SubModel.cc b/src/SubModel.cc index 8d59e5dd99aecb58aa5341da815e6c105b6fdba3..f2e0699e0a8d0e4917e8d75759cd214eb6a2e735 100644 --- a/src/SubModel.cc +++ b/src/SubModel.cc @@ -1006,15 +1006,18 @@ PacModelTable::transformPass(const lag_equivalence_table_t &unary_ops_nodes, // Associate the coefficients of the linear combination with the right components for (auto [var, coeff] : terms) - if (auto it = find_if(components.begin(), components.end(), - [&](const auto &v) { return get<0>(v) == dynamic_model.AddVariable(var); }); - it != components.end()) - get<4>(*it) = coeff; - else - { - cerr << "ERROR: the model equation defining the 'target' of 'pac_target_info(" << name << ")' contains a variable (" << symbol_table.getName(var) << ") that is not declared as a 'component'" << endl; - exit(EXIT_FAILURE); - } + { + auto tmp = dynamic_model.AddVariable(var); + if (auto it = find_if(components.begin(), components.end(), + [& tmp = tmp](const auto &v) { return get<0>(v) == tmp; }); + it != components.end()) + get<4>(*it) = coeff; + else + { + cerr << "ERROR: the model equation defining the 'target' of 'pac_target_info(" << name << ")' contains a variable (" << symbol_table.getName(var) << ") that is not declared as a 'component'" << endl; + exit(EXIT_FAILURE); + } + } // Verify that all declared components appear in that equation for (const auto &[component, growth_component, auxname, kind, coeff, growth_neutrality_param, h_indices, original_growth_component, growth_component_info] : components)