Allow borrowing as nonnull or optional pointers.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9e2805f684
commit
16b082f00d
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "../Assert.hpp"
|
||||
#include "NonNullBorrowedPtr.hpp"
|
||||
#include "OwnPtr.hpp"
|
||||
#include "BorrowedPtr.hpp"
|
||||
|
||||
namespace Arbutils::Memory {
|
||||
template <class T> class NonNullOwnPtr {
|
||||
|
@ -21,10 +21,9 @@ namespace Arbutils::Memory {
|
|||
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
|
||||
|
||||
inline NonNullBorrowedPtr<T> Borrow() { return NonNullBorrowedPtr<T>(_ptr); }
|
||||
|
||||
inline const NonNullBorrowedPtr<const T> Borrow() const{
|
||||
return NonNullBorrowedPtr<const T>(_ptr);
|
||||
}
|
||||
inline const NonNullBorrowedPtr<const T> Borrow() const { return NonNullBorrowedPtr<const T>(_ptr); }
|
||||
inline BorrowedPtr<T> BorrowOptional() { return BorrowedPtr<T>(_ptr); }
|
||||
inline const BorrowedPtr<const T> BorrowOptional() const { return BorrowedPtr<const T>(_ptr); }
|
||||
|
||||
T* operator->() noexcept { return _ptr; }
|
||||
const T* operator->() const noexcept { return _ptr; }
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include "BorrowedPtr.hpp"
|
||||
#include "NonNullBorrowedPtr.hpp"
|
||||
|
||||
namespace Arbutils::Memory {
|
||||
template <class T> class OwnPtr {
|
||||
|
@ -22,6 +23,8 @@ namespace Arbutils::Memory {
|
|||
|
||||
inline BorrowedPtr<T> Borrow() { return BorrowedPtr<T>(_ptr); }
|
||||
inline const BorrowedPtr<const T> Borrow() const { return BorrowedPtr<const T>(_ptr); }
|
||||
inline BorrowedPtr<T> BorrowNonNull() { return NonNullBorrowedPtr<T>(_ptr); }
|
||||
inline const BorrowedPtr<const T> BorrowNonNull() const { return NonNullBorrowedPtr<const T>(_ptr); }
|
||||
|
||||
T* operator->() noexcept { return _ptr; }
|
||||
const T* operator->() const noexcept { return _ptr; }
|
||||
|
|
Loading…
Reference in New Issue