More functionality for memory classes.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-29 18:09:55 +02:00
parent 872c275bc7
commit 74ac2dbbc3
4 changed files with 29 additions and 11 deletions

View File

@@ -1,9 +1,8 @@
#ifndef ARBUTILS_BORROWEDPTR_HPP
#define ARBUTILS_BORROWEDPTR_HPP
namespace Arbutils::Memory{
template <class T>
class BorrowedPtr{
namespace Arbutils::Memory {
template <class T> class BorrowedPtr {
T* _ptr;
public:
@@ -11,10 +10,15 @@ namespace Arbutils::Memory{
inline constexpr T* GetUnsafe() noexcept { return _ptr; }
inline constexpr const T* GetUnsafe() const noexcept { return _ptr; }
inline constexpr bool IsNull() const noexcept { return _ptr == nullptr; }
T* operator->() noexcept { return _ptr; }
const T* operator->() const noexcept { return _ptr; }
inline bool operator==(const BorrowedPtr& rhs) const noexcept { return _ptr == rhs._ptr; }
inline bool operator!=(const BorrowedPtr& rhs) const noexcept { return _ptr != rhs._ptr; }
inline bool operator==(const T* rhs) const noexcept { return _ptr == rhs; }
inline bool operator!=(const T* rhs) const noexcept { return _ptr != rhs; }
};
}