From 32e3ea6f2ec67e4f7ba769beaff780aa4dc4fa7c Mon Sep 17 00:00:00 2001 From: fintarin Date: Mon, 6 May 2024 01:26:04 +0400 Subject: [PATCH] Check address in IMathObject::operator== --- include/fintamath/core/IMathObject.hpp | 4 ++++ include/fintamath/core/IMathObjectCRTP.hpp | 4 ++++ 2 files changed, 8 insertions(+) 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)); }