diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-14 18:18:38 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-14 18:18:38 +0100 |
commit | 01ce0af940bd69c94a2fac8b65219262845cca98 (patch) | |
tree | 97c443782ce1cfba90b205183c8aab1e3edb0bb3 /src/utils/memory.hpp | |
parent | cb7a167c7dee2fa1a19bd09ede3bae8b140e79da (diff) |
refactor: clean sewage
Diffstat (limited to 'src/utils/memory.hpp')
-rw-r--r-- | src/utils/memory.hpp | 26 |
1 files changed, 18 insertions, 8 deletions
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 <stddef.h> + template <typename memType> memType *malloc_s(unsigned int size); template <class Target> -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<class Target, typename...Args> -unique_ptr<Target> make_unique(Args&... args); +template <typename Target, typename... Args> +UniquePtr<Target> make_unique(Args... args); #include "memory.tpp" |