Fixes for OptionalScopedPtr.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-03-27 12:03:00 +01:00
parent 29ac434679
commit c805b4eee8
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 8 additions and 8 deletions

View File

@ -14,16 +14,16 @@ namespace ArbUt {
public: public:
/// @brief Initialise a ScopedPtr with a specific raw pointer. /// @brief Initialise a ScopedPtr with a specific raw pointer.
inline ScopedPtr<T>(T* ptr) : _raw(ptr){}; inline OptionalScopedPtr<T>(T* ptr) : _raw(ptr){};
/// @brief Initialise a ScopedPtr from a copy. /// @brief Initialise a ScopedPtr from a copy.
inline ScopedPtr<T>(const ScopedPtr<T>& other) : _raw(other._raw){}; inline OptionalScopedPtr<T>(const ScopedPtr<T>& other) : _raw(other._raw){};
/// @brief Initialise a ScopedPtr with a std unique_ptr. /// @brief Initialise a ScopedPtr with a std unique_ptr.
inline ScopedPtr<T>(const std::unique_ptr<T>& other) : _raw(other.get()){}; inline OptionalScopedPtr<T>(const std::unique_ptr<T>& other) : _raw(other.get()){};
~ScopedPtr() noexcept { delete _raw; } ~OptionalScopedPtr() noexcept { delete _raw; }
/// @brief Copy operator. /// @brief Copy operator.
inline ScopedPtr<T>& operator=(const ScopedPtr<T>& rhs) { inline OptionalScopedPtr<T>& operator=(const ScopedPtr<T>& rhs) {
if (this == &rhs) { if (this == &rhs) {
return *this; return *this;
} }
@ -32,7 +32,7 @@ namespace ArbUt {
} }
/// @brief Assign operator with raw pointer. /// @brief Assign operator with raw pointer.
inline ScopedPtr<T>& operator=(T* rhs) { inline OptionalScopedPtr<T>& operator=(T* rhs) {
if (_raw == rhs) { if (_raw == rhs) {
return *this; return *this;
} }
@ -54,11 +54,11 @@ namespace ArbUt {
} }
/// @brief Check equality of two ScopedPtr objects /// @brief Check equality of two ScopedPtr objects
inline bool operator==(const ScopedPtr& rhs) const noexcept { return _raw == rhs._raw; } inline bool operator==(const OptionalScopedPtr& rhs) const noexcept { return _raw == rhs._raw; }
/// @brief Check equality of pointers /// @brief Check equality of pointers
inline bool operator==(T* rhs) const noexcept { return _raw == rhs; } inline bool operator==(T* rhs) const noexcept { return _raw == rhs; }
/// @brief Check equality of two ScopedPtr objects /// @brief Check equality of two ScopedPtr objects
inline bool operator!=(const ScopedPtr& rhs) const noexcept { return _raw != rhs._raw; } inline bool operator!=(const OptionalScopedPtr& rhs) const noexcept { return _raw != rhs._raw; }
/// @brief Check equality of pointers /// @brief Check equality of pointers
inline bool operator!=(T* rhs) const noexcept { return _raw != rhs; } inline bool operator!=(T* rhs) const noexcept { return _raw != rhs; }
}; };