Fixes assignment of raw pointers to smart pointers being broken.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-12-11 17:27:58 +01:00
parent 1119012158
commit 5ef9d5f6fc
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
5 changed files with 19 additions and 10 deletions

View File

@ -28,15 +28,17 @@ namespace ArbUt {
/// @brief Copy operator.
inline BorrowedPtr<T>& operator=(const BorrowedPtr<T>& rhs) {
if (this == &rhs)
if (this == &rhs) {
return *this;
}
_raw = rhs._raw;
return *this;
}
/// @brief Assign operator with raw pointer.
inline BorrowedPtr<T>& operator=(T* rhs) {
if (_raw == &rhs)
if (_raw == rhs) {
return *this;
}
AssertNotNull(rhs);
_raw = rhs;
return *this;

View File

@ -27,15 +27,17 @@ namespace ArbUt {
/// @brief Copy operator.
inline OptionalBorrowedPtr<T>& operator=(const OptionalBorrowedPtr<T>& rhs) {
if (this == &rhs)
if (this == &rhs) {
return *this;
}
_raw = rhs._raw;
return *this;
}
/// @brief Assign operator with raw pointer.
inline OptionalBorrowedPtr<T>& operator=(T* rhs) {
if (_raw == &rhs)
if (_raw == rhs) {
return *this;
}
_raw = rhs;
return *this;
}

View File

@ -26,16 +26,18 @@ namespace ArbUt {
/// @brief Copy operator.
inline OptionalUniquePtr<T>& operator=(const OptionalUniquePtr<T>& rhs) {
if (this == &rhs)
if (this == &rhs) {
return *this;
}
_raw = rhs._raw;
return *this;
}
/// @brief Assign operator with raw pointer.
inline OptionalUniquePtr<T>& operator=(T* rhs) {
if (_raw == &rhs)
if (_raw == rhs) {
return *this;
}
_raw = rhs;
return *this;
}

View File

@ -24,16 +24,18 @@ namespace ArbUt {
/// @brief Copy operator.
inline ScopedPtr<T>& operator=(const ScopedPtr<T>& rhs) {
if (this == &rhs)
if (this == &rhs) {
return *this;
}
_raw = rhs._raw;
return *this;
}
/// @brief Assign operator with raw pointer.
inline ScopedPtr<T>& operator=(T* rhs) {
if (_raw == &rhs)
if (_raw == rhs) {
return *this;
}
_raw = rhs;
return *this;
}

View File

@ -28,8 +28,9 @@ namespace ArbUt {
/// @brief Copy operator.
inline UniquePtr<T>& operator=(const UniquePtr<T>& rhs) {
if (this == &rhs)
if (this == &rhs) {
return *this;
}
delete _raw;
_raw = rhs._raw;
return *this;
@ -37,7 +38,7 @@ namespace ArbUt {
/// @brief Assign operator with raw pointer.
inline UniquePtr<T>& operator=(T* rhs) {
if (_raw == &rhs) {
if (_raw == rhs) {
return *this;
}
delete _raw;