diff --git a/include/fintamath/core/IMathObject.hpp b/include/fintamath/core/IMathObject.hpp index 1dd87f4b3..7d0a21ad0 100644 --- a/include/fintamath/core/IMathObject.hpp +++ b/include/fintamath/core/IMathObject.hpp @@ -36,6 +36,10 @@ class IMathObject { virtual MathObjectClass getClass() const noexcept = 0; friend bool operator==(const IMathObject &lhs, const IMathObject &rhs) { + if (&lhs == &rhs) { + return true; + } + return lhs.equalsAbstract(rhs); } diff --git a/include/fintamath/core/IMathObjectCRTP.hpp b/include/fintamath/core/IMathObjectCRTP.hpp index 6e1656f9f..5e65dd60f 100644 --- a/include/fintamath/core/IMathObjectCRTP.hpp +++ b/include/fintamath/core/IMathObjectCRTP.hpp @@ -19,6 +19,10 @@ class IMathObjectCRTP_ : public IMathObject { } bool operator==(const I_MATH_OBJECT_CRTP &rhs) const { + if (this == &rhs) { + return true; + } + return equals(cast(rhs)); }