Assert BorrowedPtr is not null when trying to dereference it.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
f59ec6c957
commit
d547046752
|
@ -2,6 +2,7 @@
|
|||
#define ARBUTILS_BORROWEDPTR_HPP
|
||||
|
||||
#include <memory>
|
||||
#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 T> Const() const noexcept {
|
||||
return BorrowedPtr<const T>(_raw);
|
||||
}
|
||||
inline BorrowedPtr<const T> Const() const noexcept { return BorrowedPtr<const T>(_raw); }
|
||||
|
||||
template <class TCast> inline BorrowedPtr<TCast> As() const {
|
||||
auto cast = dynamic_cast<TCast*>(_raw);
|
||||
|
|
Loading…
Reference in New Issue