From bcdce9633dc351d3bc7f347a165348b8fab87cd9 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 15 Feb 2022 12:33:52 +0100 Subject: refactor: reorganize files & improve classes --- src/std/memory.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/std/memory.hpp (limited to 'src/std/memory.hpp') diff --git a/src/std/memory.hpp b/src/std/memory.hpp new file mode 100644 index 0000000..e870b0b --- /dev/null +++ b/src/std/memory.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +template +memType *malloc_s(unsigned int size); + +template +class UniquePtr +{ +public: + 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; + +private: + Target *_target = nullptr; +}; + +template +UniquePtr make_unique(Args... args); + +#include "memory.tpp" -- cgit v1.2.3-18-g5258