diff --git a/src/Memory/BorrowedPtr.hpp b/src/Memory/BorrowedPtr.hpp index ee8eefa..382138d 100644 --- a/src/Memory/BorrowedPtr.hpp +++ b/src/Memory/BorrowedPtr.hpp @@ -2,6 +2,7 @@ #define ARBUTILS_BORROWEDPTR_HPP #include +#include "../Assert.hpp" namespace ArbUt { /// A borrowed pointer is used to indicate a pointer that is not owned by an object, but instead borrowed from @@ -24,7 +25,10 @@ namespace ArbUt { return *this; } - inline T* operator->() const noexcept { return _raw; } + inline T* operator->() const noexcept { + AssertNotNull(_raw); + return _raw; + } inline T* GetRaw() const noexcept { return _raw; } inline bool operator==(const BorrowedPtr& rhs) const noexcept { return _raw == rhs._raw; } @@ -32,9 +36,7 @@ namespace ArbUt { [[nodiscard]] inline constexpr bool IsNull() const noexcept { return _raw == nullptr; } - inline BorrowedPtr Const() const noexcept { - return BorrowedPtr(_raw); - } + inline BorrowedPtr Const() const noexcept { return BorrowedPtr(_raw); } template inline BorrowedPtr As() const { auto cast = dynamic_cast(_raw);