Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
endurodave committed Dec 13, 2024
1 parent c5047a2 commit 4d3e260
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions src/Delegate/Delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ class DelegateFree<RetType(Args...)> : public Delegate<RetType(Args...)> {

/// @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;
Expand Down Expand Up @@ -146,8 +144,7 @@ class DelegateFree<RetType(Args...)> : public Delegate<RetType(Args...)> {
/// @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;
}
Expand Down Expand Up @@ -213,10 +210,7 @@ class DelegateMember<TClass, RetType(Args...)> : public Delegate<RetType(Args...

/// @brief Move constructor that transfers ownership of resources.
/// @param[in] rhs The object to move from.
DelegateMember(ClassType&& rhs) noexcept : m_object(rhs.m_object), m_func(rhs.m_func) {
rhs.m_object = nullptr; // Nullify the source object to avoid double deletion
rhs.m_func = nullptr;
}
DelegateMember(ClassType&& rhs) noexcept : m_object(rhs.m_object), m_func(rhs.m_func) { }

/// @brief Default constructor creates an empty delegate.
DelegateMember() = default;
Expand Down Expand Up @@ -283,10 +277,8 @@ class DelegateMember<TClass, RetType(Args...)> : public Delegate<RetType(Args...
/// @return A reference to the current object.
ClassType& operator=(ClassType&& rhs) noexcept {
if (&rhs != this) {
m_object = rhs.m_object; // Steal the resource
m_func = rhs.m_func;
rhs.m_object = nullptr; // Nullify the source to avoid double deletion
rhs.m_func = nullptr;
m_object = rhs.m_object;
m_func = rhs.m_func;
}
return *this;
}
Expand Down Expand Up @@ -356,10 +348,7 @@ class DelegateMemberSp<TClass, RetType(Args...)> : public Delegate<RetType(Args.

/// @brief Move constructor that transfers ownership of resources.
/// @param[in] rhs The object to move from.
DelegateMemberSp(ClassType&& rhs) noexcept : m_object(rhs.m_object), m_func(rhs.m_func) {
rhs.m_object = nullptr; // Nullify the source object to avoid double deletion
rhs.m_func = nullptr;
}
DelegateMemberSp(ClassType&& rhs) noexcept : m_object(rhs.m_object), m_func(rhs.m_func) { }

/// @brief Default constructor creates an empty delegate.
DelegateMemberSp() = default;
Expand Down Expand Up @@ -426,10 +415,8 @@ class DelegateMemberSp<TClass, RetType(Args...)> : public Delegate<RetType(Args.
/// @return A reference to the current object.
ClassType& operator=(ClassType&& rhs) noexcept {
if (&rhs != this) {
m_object = rhs.m_object; // Steal the resource
m_object = rhs.m_object;
m_func = rhs.m_func;
rhs.m_object = nullptr; // Nullify the source to avoid double deletion
rhs.m_func = nullptr;
}
return *this;
}
Expand Down Expand Up @@ -483,7 +470,7 @@ class DelegateFunction; // Not defined
///
/// Depending on how usage, this may never be a issue but its worth noting.
///
/// The `DelegateMember<>` 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.
Expand All @@ -507,9 +494,7 @@ class DelegateFunction<RetType(Args...)> : public Delegate<RetType(Args...)> {

/// @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;
Expand Down Expand Up @@ -562,8 +547,7 @@ class DelegateFunction<RetType(Args...)> : public Delegate<RetType(Args...)> {
/// @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;
}
Expand Down

0 comments on commit 4d3e260

Please sign in to comment.