From 01ce0af940bd69c94a2fac8b65219262845cca98 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Feb 2022 18:18:38 +0100 Subject: refactor: clean sewage --- src/utils/memory.hpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/utils/memory.hpp') diff --git a/src/utils/memory.hpp b/src/utils/memory.hpp index 81e3757..e870b0b 100644 --- a/src/utils/memory.hpp +++ b/src/utils/memory.hpp @@ -1,23 +1,33 @@ #pragma once +#include + template memType *malloc_s(unsigned int size); template -class unique_ptr +class UniquePtr { public: - unique_ptr(Target *target); - ~unique_ptr(); + explicit UniquePtr(); + explicit UniquePtr(Target *target); + UniquePtr(const UniquePtr &unique_ptr); + UniquePtr(UniquePtr &&unique_ptr) noexcept; + + UniquePtr &operator=(const UniquePtr &unique_ptr); + + UniquePtr &operator=(UniquePtr &&unique_ptr) noexcept; + + ~UniquePtr(); - Target operator *() const; - Target *operator ->() const; + Target operator*() const; + Target *operator->() const; private: - Target *_target; + Target *_target = nullptr; }; -template -unique_ptr make_unique(Args&... args); +template +UniquePtr make_unique(Args... args); #include "memory.tpp" -- cgit v1.2.3-18-g5258