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.
mr#2134
Sébastien Villemot 2023-05-09 21:13:14 +02:00
parent 792aa64e76
commit aeff2bf48d
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 Ondra Kamenik * Copyright © 2004 Ondra Kamenik
* Copyright © 2019 Dynare Team * Copyright © 2019-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -101,7 +101,7 @@ public:
{ {
} }
bool bool
operator==(const Permutation &p) operator==(const Permutation &p) const
{ {
return permap == p.permap; return permap == p.permap;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 Ondra Kamenik * Copyright © 2004 Ondra Kamenik
* Copyright © 2019 Dynare Team * Copyright © 2019-2023 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -116,7 +116,7 @@ public:
per.apply(nvmax); per.apply(nvmax);
} }
bool bool
operator==(const PerTensorDimens &td) operator==(const PerTensorDimens &td) const
{ {
return TensorDimens::operator==(td) && per == td.per; return TensorDimens::operator==(td) && per == td.per;
} }