From a84c7ae45c5b9b467d65b338f5ddb9da60bec272 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 26 May 2020 13:44:06 +0200 Subject: [PATCH] Implements assignment, some tweaks for borrowed_ptr. --- src/Memory/borrowed_ptr.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Memory/borrowed_ptr.hpp b/src/Memory/borrowed_ptr.hpp index c6519fa..74f5e2c 100644 --- a/src/Memory/borrowed_ptr.hpp +++ b/src/Memory/borrowed_ptr.hpp @@ -10,20 +10,25 @@ private: T* _raw; public: + inline borrowed_ptr() : _raw(nullptr){}; inline borrowed_ptr(T* ptr) : _raw(ptr){}; inline borrowed_ptr(const borrowed_ptr& other) : _raw(other._raw){}; inline borrowed_ptr(const std::unique_ptr& other) : _raw(other.get()){}; ~borrowed_ptr() = default; - inline T* operator->() noexcept { return _raw; } - inline const T* operator->() const noexcept { return _raw; } + inline borrowed_ptr& operator=(const borrowed_ptr& rhs) { + _raw = rhs._raw; + return *this; + } + inline T* operator->() noexcept { return _raw; } inline T* GetRaw() noexcept { return _raw; } - inline const T* GetRaw() const noexcept { return _raw; } inline bool operator==(const borrowed_ptr& rhs) const { return _raw == rhs._raw; } inline bool operator!=(const borrowed_ptr& rhs) const { return _raw != rhs._raw; } + + [[nodiscard]] inline constexpr bool IsNull() const noexcept { return _raw == nullptr; } }; #endif // ARBUTILS_BORROWED_PTR_HPP