diff --git a/src/Delegate/Delegate.h b/src/Delegate/Delegate.h index b8660bf..84464b5 100644 --- a/src/Delegate/Delegate.h +++ b/src/Delegate/Delegate.h @@ -93,9 +93,7 @@ class DelegateFree : public Delegate { /// @brief Move constructor that transfers ownership of resources. /// @param[in] rhs The object to move from. - DelegateFree(ClassType&& rhs) noexcept : m_func(rhs.m_func) { - rhs.m_func = nullptr; // Nullify the source object to avoid double deletion - } + DelegateFree(ClassType&& rhs) noexcept : m_func(rhs.m_func) { } /// @brief Default constructor creates an empty delegate. DelegateFree() = default; @@ -146,8 +144,7 @@ class DelegateFree : public Delegate { /// @return A reference to the current object. ClassType& operator=(ClassType&& rhs) noexcept { if (&rhs != this) { - m_func = rhs.m_func; // Steal the resource - rhs.m_func = nullptr; // Nullify the source to avoid double deletion + m_func = rhs.m_func; } return *this; } @@ -213,10 +210,7 @@ class DelegateMember : public Delegate : public Delegate : public Delegate : public Delegate` class has no such limitations and works under all conditions, +/// The other delegate class has no such limitations and works under all conditions, /// including comparing two instance functions of the same class. /// /// @tparam RetType The return type of the bound delegate function. @@ -507,9 +494,7 @@ class DelegateFunction : public Delegate { /// @brief Move constructor that transfers ownership of resources. /// @param[in] rhs The object to move from. - DelegateFunction(ClassType&& rhs) noexcept : m_func(rhs.m_func) { - rhs.m_func = nullptr; // Nullify the source object to avoid double deletion - } + DelegateFunction(ClassType&& rhs) noexcept : m_func(rhs.m_func) { } /// @brief Default constructor creates an empty delegate. DelegateFunction() = default; @@ -562,8 +547,7 @@ class DelegateFunction : public Delegate { /// @return A reference to the current object. ClassType& operator=(ClassType&& rhs) noexcept { if (&rhs != this) { - m_func = rhs.m_func; // Steal the resource - rhs.m_func = nullptr; // Nullify the source to avoid double deletion + m_func = rhs.m_func; } return *this; }