Default the BorrowedPtr and OwnPtr to nullptr.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
6c5fe1bf93
commit
96b2bd61ab
|
@ -6,7 +6,7 @@ namespace Arbutils::Memory {
|
|||
T* _ptr;
|
||||
|
||||
public:
|
||||
inline BorrowedPtr() {};
|
||||
inline BorrowedPtr() { _ptr = nullptr; };
|
||||
inline explicit constexpr BorrowedPtr(T* ptr) noexcept : _ptr(ptr){};
|
||||
|
||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||
|
|
|
@ -10,9 +10,7 @@ namespace Arbutils::Memory {
|
|||
|
||||
public:
|
||||
inline NonNullBorrowedPtr(){};
|
||||
inline explicit NonNullBorrowedPtr(T* ptr) : _ptr(ptr){
|
||||
AssertNotNull(ptr);
|
||||
};
|
||||
inline explicit NonNullBorrowedPtr(T* ptr) : _ptr(ptr) { AssertNotNull(ptr); };
|
||||
|
||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Arbutils::Memory {
|
|||
T* _ptr;
|
||||
|
||||
public:
|
||||
inline OwnPtr() {};
|
||||
inline OwnPtr() { _ptr = nullptr; };
|
||||
inline explicit constexpr OwnPtr(T* ptr) noexcept : _ptr(ptr){};
|
||||
|
||||
OwnPtr<T>(const OwnPtr<T>&) = delete;
|
||||
|
@ -18,16 +18,10 @@ namespace Arbutils::Memory {
|
|||
|
||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||
inline constexpr const T* IsNull() const noexcept {
|
||||
return _ptr == nullptr;
|
||||
}
|
||||
inline constexpr const T* IsNull() const noexcept { return _ptr == nullptr; }
|
||||
|
||||
inline BorrowedPtr<T> Borrow(){
|
||||
return BorrowedPtr<T>(_ptr);
|
||||
}
|
||||
inline const BorrowedPtr<const T> Borrow() const{
|
||||
return BorrowedPtr<const T>(_ptr);
|
||||
}
|
||||
inline BorrowedPtr<T> Borrow() { return BorrowedPtr<T>(_ptr); }
|
||||
inline const BorrowedPtr<const T> Borrow() const { return BorrowedPtr<const T>(_ptr); }
|
||||
|
||||
T* operator->() noexcept { return _ptr; }
|
||||
const T* operator->() const noexcept { return _ptr; }
|
||||
|
@ -39,5 +33,4 @@ namespace Arbutils::Memory {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // ARBUTILS_OWNPTR_HPP
|
||||
|
|
Loading…
Reference in New Issue