Commit 6cf4e6dc authored by Sébastien Villemot's avatar Sébastien Villemot

Port to C++11 range-based for loops

Performed using modernize-loop-convert from clang-tidy.

Manual intervention was needed in MacroValue.cc because of a variable name
capture issue.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html
parent 80d1e1e1
This diff is collapsed.
This diff is collapsed.
...@@ -46,8 +46,8 @@ DataTree::DataTree(SymbolTable &symbol_table_arg, ...@@ -46,8 +46,8 @@ DataTree::DataTree(SymbolTable &symbol_table_arg,
DataTree::~DataTree() DataTree::~DataTree()
{ {
for (node_list_t::iterator it = node_list.begin(); it != node_list.end(); it++) for (auto & it : node_list)
delete *it; delete it;
} }
expr_t expr_t
...@@ -75,9 +75,8 @@ DataTree::AddVariableInternal(int symb_id, int lag) ...@@ -75,9 +75,8 @@ DataTree::AddVariableInternal(int symb_id, int lag)
bool bool
DataTree::ParamUsedWithLeadLagInternal() const DataTree::ParamUsedWithLeadLagInternal() const
{ {
for (variable_node_map_t::const_iterator it = variable_node_map.begin(); for (const auto & it : variable_node_map)
it != variable_node_map.end(); it++) if (symbol_table.getType(it.first.first) == eParameter && it.first.second != 0)
if (symbol_table.getType(it->first.first) == eParameter && it->first.second != 0)
return true; return true;
return false; return false;
} }
...@@ -588,9 +587,8 @@ DataTree::AddSecondDerivExternalFunction(int top_level_symb_id, const vector<exp ...@@ -588,9 +587,8 @@ DataTree::AddSecondDerivExternalFunction(int top_level_symb_id, const vector<exp
bool bool
DataTree::isSymbolUsed(int symb_id) const DataTree::isSymbolUsed(int symb_id) const
{ {
for (variable_node_map_t::const_iterator it = variable_node_map.begin(); for (const auto & it : variable_node_map)
it != variable_node_map.end(); it++) if (it.first.first == symb_id)
if (it->first.first == symb_id)
return true; return true;
if (local_variables_table.find(symb_id) != local_variables_table.end()) if (local_variables_table.find(symb_id) != local_variables_table.end())
...@@ -637,9 +635,8 @@ DataTree::getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException) ...@@ -637,9 +635,8 @@ DataTree::getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException)
bool bool
DataTree::isUnaryOpUsed(UnaryOpcode opcode) const DataTree::isUnaryOpUsed(UnaryOpcode opcode) const
{ {
for (unary_op_node_map_t::const_iterator it = unary_op_node_map.begin(); for (const auto & it : unary_op_node_map)
it != unary_op_node_map.end(); it++) if (it.first.first.second == opcode)
if (it->first.first.second == opcode)
return true; return true;
return false; return false;
...@@ -648,9 +645,8 @@ DataTree::isUnaryOpUsed(UnaryOpcode opcode) const ...@@ -648,9 +645,8 @@ DataTree::isUnaryOpUsed(UnaryOpcode opcode) const
bool bool
DataTree::isBinaryOpUsed(BinaryOpcode opcode) const DataTree::isBinaryOpUsed(BinaryOpcode opcode) const
{ {
for (binary_op_node_map_t::const_iterator it = binary_op_node_map.begin(); for (const auto & it : binary_op_node_map)
it != binary_op_node_map.end(); it++) if (it.first.second == opcode)
if (it->first.second == opcode)
return true; return true;
return false; return false;
...@@ -659,9 +655,8 @@ DataTree::isBinaryOpUsed(BinaryOpcode opcode) const ...@@ -659,9 +655,8 @@ DataTree::isBinaryOpUsed(BinaryOpcode opcode) const
bool bool
DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const
{ {
for (trinary_op_node_map_t::const_iterator it = trinary_op_node_map.begin(); for (const auto & it : trinary_op_node_map)
it != trinary_op_node_map.end(); it++) if (it.first.second == opcode)
if (it->first.second == opcode)
return true; return true;
return false; return false;
...@@ -670,9 +665,8 @@ DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const ...@@ -670,9 +665,8 @@ DataTree::isTrinaryOpUsed(TrinaryOpcode opcode) const
bool bool
DataTree::isExternalFunctionUsed(int symb_id) const DataTree::isExternalFunctionUsed(int symb_id) const
{ {
for (external_function_node_map_t::const_iterator it = external_function_node_map.begin(); for (const auto & it : external_function_node_map)
it != external_function_node_map.end(); it++) if (it.first.second == symb_id)
if (it->first.second == symb_id)
return true; return true;
return false; return false;
...@@ -681,9 +675,8 @@ DataTree::isExternalFunctionUsed(int symb_id) const ...@@ -681,9 +675,8 @@ DataTree::isExternalFunctionUsed(int symb_id) const
bool bool
DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const
{ {
for (first_deriv_external_function_node_map_t::const_iterator it = first_deriv_external_function_node_map.begin(); for (const auto & it : first_deriv_external_function_node_map)
it != first_deriv_external_function_node_map.end(); it++) if (it.first.second == symb_id)
if (it->first.second == symb_id)
return true; return true;
return false; return false;
...@@ -692,9 +685,8 @@ DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const ...@@ -692,9 +685,8 @@ DataTree::isFirstDerivExternalFunctionUsed(int symb_id) const
bool bool
DataTree::isSecondDerivExternalFunctionUsed(int symb_id) const DataTree::isSecondDerivExternalFunctionUsed(int symb_id) const
{ {
for (second_deriv_external_function_node_map_t::const_iterator it = second_deriv_external_function_node_map.begin(); for (const auto & it : second_deriv_external_function_node_map)
it != second_deriv_external_function_node_map.end(); it++) if (it.first.second == symb_id)
if (it->first.second == symb_id)
return true; return true;
return false; return false;
...@@ -704,10 +696,9 @@ int ...@@ -704,10 +696,9 @@ int
DataTree::minLagForSymbol(int symb_id) const DataTree::minLagForSymbol(int symb_id) const
{ {
int r = 0; int r = 0;
for (variable_node_map_t::const_iterator it = variable_node_map.begin(); for (const auto & it : variable_node_map)
it != variable_node_map.end(); ++it) if (it.first.first == symb_id && it.first.second < r)
if (it->first.first == symb_id && it->first.second < r) r = it.first.second;
r = it->first.second;
return r; return r;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -116,9 +116,8 @@ inline int ...@@ -116,9 +116,8 @@ inline int
ExternalFunctionsTable::get_total_number_of_unique_model_block_external_functions() const ExternalFunctionsTable::get_total_number_of_unique_model_block_external_functions() const
{ {
int number_of_unique_model_block_external_functions = 0; int number_of_unique_model_block_external_functions = 0;
for (external_function_table_type::const_iterator it = externalFunctionTable.begin(); for (auto it : externalFunctionTable)
it != externalFunctionTable.end(); it++) if (it.second.nargs > 0)
if (it->second.nargs > 0)
number_of_unique_model_block_external_functions++; number_of_unique_model_block_external_functions++;
return number_of_unique_model_block_external_functions; return number_of_unique_model_block_external_functions;
......
...@@ -48,9 +48,8 @@ ModFile::ModFile(WarningConsolidation &warnings_arg) ...@@ -48,9 +48,8 @@ ModFile::ModFile(WarningConsolidation &warnings_arg)
ModFile::~ModFile() ModFile::~ModFile()
{ {
for (vector<Statement *>::iterator it = statements.begin(); for (auto & statement : statements)
it != statements.end(); it++) delete statement;
delete (*it);
} }
void void
...@@ -112,9 +111,8 @@ ModFile::addStatementAtFront(Statement *st) ...@@ -112,9 +111,8 @@ ModFile::addStatementAtFront(Statement *st)
void void
ModFile::checkPass(bool nostrict, bool stochastic) ModFile::checkPass(bool nostrict, bool stochastic)
{ {
for (vector<Statement *>::iterator it = statements.begin(); for (auto & statement : statements)
it != statements.end(); it++) statement->checkPass(mod_file_struct, warnings);
(*it)->checkPass(mod_file_struct, warnings);
// Check the steady state block // Check the steady state block
steady_state_model.checkPass(mod_file_struct, warnings); steady_state_model.checkPass(mod_file_struct, warnings);
...@@ -332,8 +330,8 @@ ModFile::checkPass(bool nostrict, bool stochastic) ...@@ -332,8 +330,8 @@ ModFile::checkPass(bool nostrict, bool stochastic)
if (unusedExo.size() > 0) if (unusedExo.size() > 0)
{ {
ostringstream unused_exos; ostringstream unused_exos;
for (set<int>::iterator it = unusedExo.begin(); it != unusedExo.end(); it++) for (int it : unusedExo)
unused_exos << symbol_table.getName(*it) << " "; unused_exos << symbol_table.getName(it) << " ";
if (nostrict) if (nostrict)
warnings << "WARNING: " << unused_exos.str() warnings << "WARNING: " << unused_exos.str()
...@@ -358,10 +356,10 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const ...@@ -358,10 +356,10 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
if (nostrict) if (nostrict)
{ {
set<int> unusedEndogs = dynamic_model.findUnusedEndogenous(); set<int> unusedEndogs = dynamic_model.findUnusedEndogenous();
for (set<int>::iterator it = unusedEndogs.begin(); it != unusedEndogs.end(); it++) for (int unusedEndog : unusedEndogs)
{ {
symbol_table.changeType(*it, eUnusedEndogenous); symbol_table.changeType(unusedEndog, eUnusedEndogenous);
warnings << "WARNING: '" << symbol_table.getName(*it) warnings << "WARNING: '" << symbol_table.getName(unusedEndog)
<< "' not used in model block, removed by nostrict command-line option" << endl; << "' not used in model block, removed by nostrict command-line option" << endl;
} }
} }
...@@ -462,9 +460,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const ...@@ -462,9 +460,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
if (mod_file_struct.ramsey_model_present) if (mod_file_struct.ramsey_model_present)
{ {
StaticModel *planner_objective = NULL; StaticModel *planner_objective = NULL;
for (vector<Statement *>::iterator it = statements.begin(); it != statements.end(); it++) for (auto & statement : statements)
{ {
PlannerObjectiveStatement *pos = dynamic_cast<PlannerObjectiveStatement *>(*it); PlannerObjectiveStatement *pos = dynamic_cast<PlannerObjectiveStatement *>(statement);
if (pos != NULL) if (pos != NULL)
planner_objective = pos->getPlannerObjective(); planner_objective = pos->getPlannerObjective();
} }
...@@ -597,9 +595,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const ...@@ -597,9 +595,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
} }
if (mod_file_struct.ramsey_policy_present) if (mod_file_struct.ramsey_policy_present)
for (vector<Statement *>::iterator it = statements.begin(); it != statements.end(); it++) for (auto & statement : statements)
{ {
RamseyPolicyStatement *rps = dynamic_cast<RamseyPolicyStatement *>(*it); RamseyPolicyStatement *rps = dynamic_cast<RamseyPolicyStatement *>(statement);
if (rps != NULL) if (rps != NULL)
rps->checkRamseyPolicyList(); rps->checkRamseyPolicyList();
} }
...@@ -727,9 +725,8 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri ...@@ -727,9 +725,8 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri
} }
} }
for (vector<Statement *>::iterator it = statements.begin(); for (auto & statement : statements)
it != statements.end(); it++) statement->computingPass();
(*it)->computingPass();
} }
void void
...@@ -848,14 +845,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo ...@@ -848,14 +845,14 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
if (parallel_local_files.size() > 0) if (parallel_local_files.size() > 0)
{ {
mOutputFile << "options_.parallel_info.local_files = {" << endl; mOutputFile << "options_.parallel_info.local_files = {" << endl;
for (size_t i = 0; i < parallel_local_files.size(); i++) for (const auto & parallel_local_file : parallel_local_files)
{ {
size_t j = parallel_local_files[i].find_last_of("/\\"); size_t j = parallel_local_file.find_last_of("/\\");
if (j == string::npos) if (j == string::npos)
mOutputFile << "'', '" << parallel_local_files[i] << "';" << endl; mOutputFile << "'', '" << parallel_local_file << "';" << endl;
else else
mOutputFile << "'" << parallel_local_files[i].substr(0, j+1) << "', '" mOutputFile << "'" << parallel_local_file.substr(0, j+1) << "', '"
<< parallel_local_files[i].substr(j+1, string::npos) << "';" << endl; << parallel_local_file.substr(j+1, string::npos) << "';" << endl;
} }
mOutputFile << "};" << endl; mOutputFile << "};" << endl;
} }
...@@ -985,14 +982,13 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo ...@@ -985,14 +982,13 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
// (*it)->writeOutput(mOutputFile, basename, minimal_workspace); // (*it)->writeOutput(mOutputFile, basename, minimal_workspace);
// dynamic_model.writeVarExpectationFunctions(mOutputFile); // dynamic_model.writeVarExpectationFunctions(mOutputFile);
for (vector<Statement *>::const_iterator it = statements.begin(); for (auto statement : statements)
it != statements.end(); it++)
{ {
(*it)->writeOutput(mOutputFile, basename, minimal_workspace); statement->writeOutput(mOutputFile, basename, minimal_workspace);
/* Special treatment for initval block: insert initial values for the /* Special treatment for initval block: insert initial values for the
auxiliary variables and initialize exo det */ auxiliary variables and initialize exo det */
InitValStatement *ivs = dynamic_cast<InitValStatement *>(*it); InitValStatement *ivs = dynamic_cast<InitValStatement *>(statement);
if (ivs != NULL) if (ivs != NULL)
{ {
static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel); static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel);
...@@ -1000,17 +996,17 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo ...@@ -1000,17 +996,17 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
} }
// Special treatment for endval block: insert initial values for the auxiliary variables // Special treatment for endval block: insert initial values for the auxiliary variables
EndValStatement *evs = dynamic_cast<EndValStatement *>(*it); EndValStatement *evs = dynamic_cast<EndValStatement *>(statement);
if (evs != NULL) if (evs != NULL)
static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel); static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel);
// Special treatment for load params and steady state statement: insert initial values for the auxiliary variables // Special treatment for load params and steady state statement: insert initial values for the auxiliary variables
LoadParamsAndSteadyStateStatement *lpass = dynamic_cast<LoadParamsAndSteadyStateStatement *>(*it); LoadParamsAndSteadyStateStatement *lpass = dynamic_cast<LoadParamsAndSteadyStateStatement *>(statement);
if (lpass && !no_static) if (lpass && !no_static)
static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel); static_model.writeAuxVarInitval(mOutputFile, oMatlabOutsideModel);
// Special treatement for Var Models // Special treatement for Var Models
VarModelStatement *vms = dynamic_cast<VarModelStatement *>(*it); VarModelStatement *vms = dynamic_cast<VarModelStatement *>(statement);
if (vms != NULL) if (vms != NULL)
vms->createVarModelMFunction(mOutputFile, dynamic_model.getVarExpectationFunctionsToWrite()); vms->createVarModelMFunction(mOutputFile, dynamic_model.getVarExpectationFunctionsToWrite());
} }
...@@ -1162,9 +1158,8 @@ ModFile::writeModelC(const string &basename) const ...@@ -1162,9 +1158,8 @@ ModFile::writeModelC(const string &basename) const
} }
// Print statements // Print statements
for (vector<Statement *>::const_iterator it = statements.begin(); for (auto statement : statements)
it != statements.end(); it++) statement->writeCOutput(mDriverCFile, basename);
(*it)->writeCOutput(mDriverCFile, basename);
mDriverCFile << "} DynareInfo;" << endl; mDriverCFile << "} DynareInfo;" << endl;
mDriverCFile.close(); mDriverCFile.close();
...@@ -1267,9 +1262,8 @@ ModFile::writeModelCC(const string &basename) const ...@@ -1267,9 +1262,8 @@ ModFile::writeModelCC(const string &basename) const
} }
// Print statements // Print statements
for (vector<Statement *>::const_iterator it = statements.begin(); for (auto statement : statements)
it != statements.end(); it++) statement->writeCOutput(mDriverCFile, basename);
(*it)->writeCOutput(mDriverCFile, basename);
mDriverCFile << "};" << endl; mDriverCFile << "};" << endl;
mDriverCFile.close(); mDriverCFile.close();
...@@ -1404,9 +1398,8 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output, ...@@ -1404,9 +1398,8 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output,
steady_state_model.writeSteadyStateFile(basename, mod_file_struct.ramsey_model_present, true); steady_state_model.writeSteadyStateFile(basename, mod_file_struct.ramsey_model_present, true);
// Print statements (includes parameter values) // Print statements (includes parameter values)
for (vector<Statement *>::const_iterator it = statements.begin(); for (auto statement : statements)
it != statements.end(); it++) statement->writeJuliaOutput(jlOutputFile, basename);
(*it)->writeJuliaOutput(jlOutputFile, basename);
jlOutputFile << "model_.static = " << basename << "Static.static!" << endl jlOutputFile << "model_.static = " << basename << "Static.static!" << endl
<< "model_.dynamic = " << basename << "Dynamic.dynamic!" << endl << "model_.dynamic = " << basename << "Dynamic.dynamic!" << endl
......
This diff is collapsed.
...@@ -106,12 +106,11 @@ InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_ar ...@@ -106,12 +106,11 @@ InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_ar
void void
InitOrEndValStatement::fillEvalContext(eval_context_t &eval_context) const InitOrEndValStatement::fillEvalContext(eval_context_t &eval_context) const
{ {
for (init_values_t::const_iterator it = init_values.begin(); for (const auto & init_value : init_values)
it != init_values.end(); it++)
{ {
try try
{ {
eval_context[it->first] = (it->second)->eval(eval_context); eval_context[init_value.first] = (init_value.second)->eval(eval_context);
} }
catch (ExprNode::EvalException &e) catch (ExprNode::EvalException &e)
{ {
...@@ -138,10 +137,9 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type) ...@@ -138,10 +137,9 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type)
} }
set<int>::iterator sit; set<int>::iterator sit;
for (init_values_t::const_iterator it = init_values.begin(); for (const auto & init_value : init_values)
it != init_values.end(); it++)
{ {
sit = unused.find(it->first); sit = unused.find(init_value.first);
if (sit != unused.end()) if (sit != unused.end())
unused.erase(sit); unused.erase(sit);
} }
...@@ -151,11 +149,10 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type) ...@@ -151,11 +149,10 @@ InitOrEndValStatement::getUninitializedVariables(SymbolType type)
void void
InitOrEndValStatement::writeInitValues(ostream &output) const InitOrEndValStatement::writeInitValues(ostream &output) const
{ {
for (init_values_t::const_iterator it = init_values.begin(); for (const auto & init_value : init_values)
it != init_values.end(); it++)
{ {
const int symb_id = it->first; const int symb_id = init_value.first;
const expr_t expression = it->second; const expr_t expression = init_value.second;
SymbolType type = symbol_table.getType(symb_id); SymbolType type = symbol_table.getType(symb_id);
int tsid = symbol_table.getTypeSpecificID(symb_id) + 1; int tsid = symbol_table.getTypeSpecificID(symb_id) + 1;
...@@ -203,16 +200,16 @@ InitValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat ...@@ -203,16 +200,16 @@ InitValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
if (endogs.size() > 0) if (endogs.size() > 0)
{ {
cerr << "ERROR: You have not set the following endogenous variables in initval:"; cerr << "ERROR: You have not set the following endogenous variables in initval:";
for (set<int>::const_iterator it = endogs.begin(); it != endogs.end(); it++) for (int endog : endogs)
cerr << " " << symbol_table.getName(*it); cerr << " " << symbol_table.getName(endog);
cerr << endl; cerr << endl;
} }
if (exogs.size() > 0) if (exogs.size() > 0)
{ {
cerr << "ERROR: You have not set the following exogenous variables in initval:"; cerr << "ERROR: You have not set the following exogenous variables in initval:";
for (set<int>::const_iterator it = exogs.begin(); it != exogs.end(); it++) for (int exog : exogs)
cerr << " " << symbol_table.getName(*it); cerr << " " << symbol_table.getName(exog);
cerr << endl; cerr << endl;
} }
...@@ -267,16 +264,16 @@ EndValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati ...@@ -267,16 +264,16 @@ EndValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidati
if (endogs.size() > 0) if (endogs.size() > 0)
{ {
cerr << "ERROR: You have not set the following endogenous variables in endval:"; cerr << "ERROR: You have not set the following endogenous variables in endval:";
for (set<int>::const_iterator it = endogs.begin(); it != endogs.end(); it++) for (int endog : endogs)
cerr << " " << symbol_table.getName(*it); cerr << " " << symbol_table.getName(endog);
cerr << endl; cerr << endl;
} }
if (exogs.size() > 0) if (exogs.size() > 0)
{ {
cerr << "ERROR: You have not set the following exogenous variables in endval:"; cerr << "ERROR: You have not set the following exogenous variables in endval:";
for (set<int>::const_iterator it = exogs.begin(); it != exogs.end(); it++) for (int exog : exogs)
cerr << " " << symbol_table.getName(*it); cerr << " " << symbol_table.getName(exog);
cerr << endl; cerr << endl;
} }
...@@ -325,14 +322,13 @@ HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat ...@@ -325,14 +322,13 @@ HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
set<int> unused_exo = symbol_table.getExogenous(); set<int> unused_exo = symbol_table.getExogenous();
set<int>::iterator sit; set<int>::iterator sit;
for (hist_values_t::const_iterator it = hist_values.begin(); for (const auto & hist_value : hist_values)
it != hist_values.end(); it++)
{ {
sit = unused_endo.find(it->first.first); sit = unused_endo.find(hist_value.first.first);
if (sit != unused_endo.end()) if (sit != unused_endo.end())
unused_endo.erase(sit); unused_endo.erase(sit);
sit = unused_exo.find(it->first.first); sit = unused_exo.find(hist_value.first.first);
if (sit != unused_exo.end()) if (sit != unused_exo.end())
unused_exo.erase(sit); unused_exo.erase(sit);
} }
...@@ -340,16 +336,16 @@ HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat ...@@ -340,16 +336,16 @@ HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidat
if (unused_endo.size() > 0) if (unused_endo.size() > 0)
{ {
cerr << "ERROR: You have not set the following endogenous variables in histval:"; cerr << "ERROR: You have not set the following endogenous variables in histval:";
for (set<int>::const_iterator it = unused_endo.begin(); it != unused_endo.end(); it++) for (int it : unused_endo)
cerr << " " << symbol_table.getName(*it); cerr << " " << symbol_table.getName(it);
cerr << endl; cerr << endl;
} }
if (unused_exo.size() > 0) if (unused_exo.size() > 0)
{ {
cerr << "ERROR: You have not set the following exogenous variables in endval:"; cerr << "ERROR: You have not set the following exogenous variables in endval:";
for (set<int>::const_iterator it = unused_exo.begin(); it != unused_exo.end(); it++) for (int it : unused_exo)
cerr << " " << symbol_table.getName(*it); cerr << " " << symbol_table.getName(it);
cerr << endl; cerr << endl;
} }
...@@ -369,12 +365,11 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini ...@@ -369,12 +365,11 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
<< "M_.exo_histval = zeros(M_.exo_nbr,M_.maximum_lag);" << endl << "M_.exo_histval = zeros(M_.exo_nbr,M_.maximum_lag);" << endl
<< "M_.exo_det_histval = zeros(M_.exo_det_nbr,M_.maximum_lag);" << endl; << "M_.exo_det_histval = zeros(M_.exo_det_nbr,M_.maximum_lag);" << endl;
for (hist_values_t::const_iterator it = hist_values.begin(); for (const auto & hist_value : hist_values)
it != hist_values.end(); it++)
{ {
int symb_id = it->first.first; int symb_id = hist_value.first.first;
int lag = it->first.second; int lag = hist_value.first.second;
const expr_t expression = it->second; const expr_t expression = hist_value.second;
SymbolType type = symbol_table.getType(symb_id); SymbolType type = symbol_table.getType(symb_id);