From aeff2bf48d750812d42b15a470a57fc45f2af315 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 9 May 2023 21:13:14 +0200
Subject: [PATCH] Fix GCC 13 warning about ambiguity of operator==() in C++20

In C++20, a==b can also be implicitly rewritten as b==a, assuming
commutativity. But if the operator==(const &) is not declared as const, and is
thus asymmetric, this results in an ambiguity because neither of a==b or b==a
is a better match according to the overload resolution rules.
---
 mex/sources/libkorder/tl/permutation.hh | 4 ++--
 mex/sources/libkorder/tl/ps_tensor.hh   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mex/sources/libkorder/tl/permutation.hh b/mex/sources/libkorder/tl/permutation.hh
index fb5c2d5a73..19c4a50ac4 100644
--- a/mex/sources/libkorder/tl/permutation.hh
+++ b/mex/sources/libkorder/tl/permutation.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -101,7 +101,7 @@ public:
   {
   }
   bool
-  operator==(const Permutation &p)
+  operator==(const Permutation &p) const
   {
     return permap == p.permap;
   }
diff --git a/mex/sources/libkorder/tl/ps_tensor.hh b/mex/sources/libkorder/tl/ps_tensor.hh
index 5018549c78..e981f31a8d 100644
--- a/mex/sources/libkorder/tl/ps_tensor.hh
+++ b/mex/sources/libkorder/tl/ps_tensor.hh
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2004 Ondra Kamenik
- * Copyright © 2019 Dynare Team
+ * Copyright © 2019-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -116,7 +116,7 @@ public:
     per.apply(nvmax);
   }
   bool
-  operator==(const PerTensorDimens &td)
+  operator==(const PerTensorDimens &td) const
   {
     return TensorDimens::operator==(td) && per == td.per;
   }
-- 
GitLab