Default the BorrowedPtr and OwnPtr to nullptr.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-03-30 17:41:08 +02:00
parent 6c5fe1bf93
commit 96b2bd61ab
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 7 additions and 16 deletions

View File

@ -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; }

View File

@ -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; }

View File

@ -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