From 65868ec3d920cc3594f74bcdfe99031f193bbf2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 18 Jul 2024 12:11:22 +0200
Subject: [PATCH] C++20 modernization: use std::ranges::equal

---
 src/DataTree.cc          | 4 ++--
 src/macro/Expressions.cc | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/DataTree.cc b/src/DataTree.cc
index 6deb8b79..3f7b452e 100644
--- a/src/DataTree.cc
+++ b/src/DataTree.cc
@@ -959,8 +959,8 @@ DataTree::writeToFileIfModified(stringstream& new_contents, const filesystem::pa
 {
   ifstream old_file {filename, ios::in | ios::binary};
   if (old_file.is_open()
-      && equal(istreambuf_iterator<char> {old_file}, istreambuf_iterator<char> {},
-               istreambuf_iterator<char> {new_contents}, istreambuf_iterator<char> {}))
+      && ranges::equal(istreambuf_iterator<char> {old_file}, istreambuf_iterator<char> {},
+                       istreambuf_iterator<char> {new_contents}, istreambuf_iterator<char> {}))
     return;
   old_file.close();
 
diff --git a/src/macro/Expressions.cc b/src/macro/Expressions.cc
index b1e671a9..04a33a8b 100644
--- a/src/macro/Expressions.cc
+++ b/src/macro/Expressions.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2023 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -316,10 +316,10 @@ String::cast_bool([[maybe_unused]] Environment& env) const
 {
   auto f = [](const char& a, const char& b) { return (tolower(a) == tolower(b)); };
 
-  if (string tf = "true"; equal(value.begin(), value.end(), tf.begin(), tf.end(), f))
+  if (ranges::equal(value, "true"s, f))
     return make_shared<Bool>(true);
 
-  if (string tf = "false"; equal(value.begin(), value.end(), tf.begin(), tf.end(), f))
+  if (ranges::equal(value, "false"s, f))
     return make_shared<Bool>(false);
 
   try
-- 
GitLab