diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 78ae0ce395eaac2886a2ee78ae444e7645cc9811..9e80707225f50d6e658c0eb9b2b26e2077620ecf 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -23,6 +23,7 @@ #include <cstdlib> #include <iostream> #include <numeric> +#include <ranges> #include <regex> #include <sstream> #include <string_view> @@ -3485,18 +3486,18 @@ void DynamicModel::detrendEquations() { // We go backwards in the list of trend_vars, to deal correctly with I(2) processes - for (auto it = nonstationary_symbols_map.crbegin(); it != nonstationary_symbols_map.crend(); ++it) + for (const auto& it : std::ranges::reverse_view(nonstationary_symbols_map)) { for (auto& equation : equations) { equation = dynamic_cast<BinaryOpNode*>( - equation->detrend(it->first, it->second.first, it->second.second)); + equation->detrend(it.first, it.second.first, it.second.second)); assert(equation); } for (auto& equation : static_only_equations) { equation = dynamic_cast<BinaryOpNode*>( - equation->detrend(it->first, it->second.first, it->second.second)); + equation->detrend(it.first, it.second.first, it.second.second)); assert(equation); } } diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc index a2f7a7bae37255a0ee83bcbf784cc735865a4d62..5524712337a66108ae66b1766c731bdf69f64071 100644 --- a/src/ModelEquationBlock.cc +++ b/src/ModelEquationBlock.cc @@ -19,6 +19,7 @@ #include <algorithm> #include <cassert> +#include <ranges> #include <sstream> #include "ModelEquationBlock.hh" @@ -385,10 +386,10 @@ void Epilogue::detrend(const map<int, expr_t>& trend_symbols_map, const nonstationary_symbols_map_t& nonstationary_symbols_map) { - for (auto it = nonstationary_symbols_map.crbegin(); it != nonstationary_symbols_map.crend(); ++it) + for (const auto& it : ranges::reverse_view(nonstationary_symbols_map)) for (auto& [symb_id, expr] : dynamic_def_table) { - expr = expr->detrend(it->first, it->second.first, it->second.second); + expr = expr->detrend(it.first, it.second.first, it.second.second); assert(expr); } diff --git a/src/VariableDependencyGraph.cc b/src/VariableDependencyGraph.cc index d176417aa542c081c1920ab6550405252ca33ffa..7e649ca38a923107627d8c382149ad85304c8346 100644 --- a/src/VariableDependencyGraph.cc +++ b/src/VariableDependencyGraph.cc @@ -29,6 +29,7 @@ #include <boost/graph/strong_components.hpp> #include <boost/graph/topological_sort.hpp> #pragma GCC diagnostic pop +#include <ranges> using namespace boost; @@ -325,8 +326,8 @@ VariableDependencyGraph::reorderRecursiveVariables(const set<int>& feedback_vert auto v_index = get(vertex_index, G); // Suppress feedback vertices, in decreasing order - for (auto it = feedback_vertices.rbegin(); it != feedback_vertices.rend(); ++it) - G.suppress(*it); + for (int feedback_vertex : ranges::reverse_view(feedback_vertices)) + G.suppress(feedback_vertex); bool something_has_been_done = true; while (something_has_been_done)