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;
|
T* _ptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline BorrowedPtr() {};
|
inline BorrowedPtr() { _ptr = nullptr; };
|
||||||
inline explicit constexpr BorrowedPtr(T* ptr) noexcept : _ptr(ptr){};
|
inline explicit constexpr BorrowedPtr(T* ptr) noexcept : _ptr(ptr){};
|
||||||
|
|
||||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||||
|
|
|
@ -10,9 +10,7 @@ namespace Arbutils::Memory {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline NonNullBorrowedPtr(){};
|
inline NonNullBorrowedPtr(){};
|
||||||
inline explicit NonNullBorrowedPtr(T* ptr) : _ptr(ptr){
|
inline explicit NonNullBorrowedPtr(T* ptr) : _ptr(ptr) { AssertNotNull(ptr); };
|
||||||
AssertNotNull(ptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Arbutils::Memory {
|
||||||
T* _ptr;
|
T* _ptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline OwnPtr() {};
|
inline OwnPtr() { _ptr = nullptr; };
|
||||||
inline explicit constexpr OwnPtr(T* ptr) noexcept : _ptr(ptr){};
|
inline explicit constexpr OwnPtr(T* ptr) noexcept : _ptr(ptr){};
|
||||||
|
|
||||||
OwnPtr<T>(const OwnPtr<T>&) = delete;
|
OwnPtr<T>(const OwnPtr<T>&) = delete;
|
||||||
|
@ -18,16 +18,10 @@ namespace Arbutils::Memory {
|
||||||
|
|
||||||
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
|
||||||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||||
inline constexpr const T* IsNull() const noexcept {
|
inline constexpr const T* IsNull() const noexcept { return _ptr == nullptr; }
|
||||||
return _ptr == nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BorrowedPtr<T> Borrow(){
|
inline BorrowedPtr<T> Borrow() { return BorrowedPtr<T>(_ptr); }
|
||||||
return BorrowedPtr<T>(_ptr);
|
inline const BorrowedPtr<const T> Borrow() const { return BorrowedPtr<const T>(_ptr); }
|
||||||
}
|
|
||||||
inline const BorrowedPtr<const T> Borrow() const{
|
|
||||||
return BorrowedPtr<const T>(_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
T* operator->() noexcept { return _ptr; }
|
T* operator->() noexcept { return _ptr; }
|
||||||
const T* operator->() const noexcept { return _ptr; }
|
const T* operator->() const noexcept { return _ptr; }
|
||||||
|
@ -39,5 +33,4 @@ namespace Arbutils::Memory {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ARBUTILS_OWNPTR_HPP
|
#endif // ARBUTILS_OWNPTR_HPP
|
||||||
|
|
Loading…
Reference in New Issue