From 0e49c58647d47b3bb1495a5896637f80395966f9 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 13 Dec 2020 11:51:47 +0100 Subject: [PATCH] Delete comparison with nullptr for non-null pointers. --- src/Memory/__BorrowedPtr.hpp | 4 ++++ src/Memory/__UniquePtr.hpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Memory/__BorrowedPtr.hpp b/src/Memory/__BorrowedPtr.hpp index fb6af2b..08124cf 100644 --- a/src/Memory/__BorrowedPtr.hpp +++ b/src/Memory/__BorrowedPtr.hpp @@ -57,10 +57,14 @@ namespace ArbUt { inline bool operator==(const BorrowedPtr& rhs) const noexcept { return _raw == rhs._raw; } /// @brief Check equality of pointers inline bool operator==(T* rhs) const noexcept { return _raw == rhs; } + /// @brief Delete comparison with nullptr, BorrowedPtr can't be null + inline bool operator==(std::nullptr_t) const = delete; /// @brief Check equality of two BorrowedPtr objects inline bool operator!=(const BorrowedPtr& rhs) const noexcept { return _raw != rhs._raw; } /// @brief Check equality of pointers inline bool operator!=(T* rhs) const noexcept { return _raw != rhs; } + /// @brief Delete comparison with nullptr, BorrowedPtr can't be null + inline bool operator!=(std::nullptr_t) const = delete; /// @brief Returns a const version of the underlying pointer. inline BorrowedPtr Const() const noexcept { return BorrowedPtr(_raw); } diff --git a/src/Memory/__UniquePtr.hpp b/src/Memory/__UniquePtr.hpp index d329064..b114783 100644 --- a/src/Memory/__UniquePtr.hpp +++ b/src/Memory/__UniquePtr.hpp @@ -61,10 +61,14 @@ namespace ArbUt { inline bool operator==(const UniquePtr& rhs) const noexcept { return _raw == rhs._raw; } /// @brief Check equality of pointers inline bool operator==(T* rhs) const noexcept { return _raw == rhs; } + /// @brief Delete comparison with nullptr, UniquePtr can't be null + inline bool operator==(std::nullptr_t) const = delete; /// @brief Check equality of two UniquePtr objects inline bool operator!=(const UniquePtr& rhs) const noexcept { return _raw != rhs._raw; } /// @brief Check equality of pointers inline bool operator!=(T* rhs) const noexcept { return _raw != rhs; } + /// @brief Delete comparison with nullptr, UniquePtr can't be null + inline bool operator!=(std::nullptr_t) const = delete; }; }