From 4d97aa3531cb1fab179875ed7c948d6ba062bb0f Mon Sep 17 00:00:00 2001
From: MichelJuillard <michel.juillard@mjui.fr>
Date: Sun, 17 Dec 2023 11:11:57 +0100
Subject: [PATCH] Julia: Revert "Simplify a few loops using
 std::ranges::reverse_view"

This reverts commit c2d6ab8ee0935d6093dc4dcbe89ea594af71050c.
---
 src/DynamicModel.cc            | 7 +++----
 src/ModelEquationBlock.cc      | 5 ++---
 src/VariableDependencyGraph.cc | 5 ++---
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc
index 1b1e6c31..d0270aa1 100644
--- a/src/DynamicModel.cc
+++ b/src/DynamicModel.cc
@@ -23,7 +23,6 @@
 #include <cstdlib>
 #include <iostream>
 #include <numeric>
-#include <ranges>
 #include <regex>
 #include <sstream>
 #include <string_view>
@@ -3486,18 +3485,18 @@ void
 DynamicModel::detrendEquations()
 {
   // We go backwards in the list of trend_vars, to deal correctly with I(2) processes
-  for (const auto& it : std::ranges::reverse_view(nonstationary_symbols_map))
+  for (auto it = nonstationary_symbols_map.crbegin(); it != nonstationary_symbols_map.crend(); ++it)
     {
       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 1cbc65e8..47842710 100644
--- a/src/ModelEquationBlock.cc
+++ b/src/ModelEquationBlock.cc
@@ -19,7 +19,6 @@
 
 #include <algorithm>
 #include <cassert>
-#include <ranges>
 #include <sstream>
 
 #include "ModelEquationBlock.hh"
@@ -390,10 +389,10 @@ void
 Epilogue::detrend(const map<int, expr_t>& trend_symbols_map,
                   const nonstationary_symbols_map_t& nonstationary_symbols_map)
 {
-  for (const auto& it : ranges::reverse_view(nonstationary_symbols_map))
+  for (auto it = nonstationary_symbols_map.crbegin(); it != nonstationary_symbols_map.crend(); ++it)
     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 7e649ca3..d176417a 100644
--- a/src/VariableDependencyGraph.cc
+++ b/src/VariableDependencyGraph.cc
@@ -29,7 +29,6 @@
 #include <boost/graph/strong_components.hpp>
 #include <boost/graph/topological_sort.hpp>
 #pragma GCC diagnostic pop
-#include <ranges>
 
 using namespace boost;
 
@@ -326,8 +325,8 @@ VariableDependencyGraph::reorderRecursiveVariables(const set<int>& feedback_vert
   auto v_index = get(vertex_index, G);
 
   // Suppress feedback vertices, in decreasing order
-  for (int feedback_vertex : ranges::reverse_view(feedback_vertices))
-    G.suppress(feedback_vertex);
+  for (auto it = feedback_vertices.rbegin(); it != feedback_vertices.rend(); ++it)
+    G.suppress(*it);
 
   bool something_has_been_done = true;
   while (something_has_been_done)
-- 
GitLab