summaryrefslogtreecommitdiff
path: root/src/std/memory.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-02-15 12:33:52 +0100
committerHampusM <hampus@hampusmat.com>2022-02-15 12:33:52 +0100
commitbcdce9633dc351d3bc7f347a165348b8fab87cd9 (patch)
tree88c2f5d8f0c5fac2bca28e4b543e5209f3bc98fb /src/std/memory.hpp
parent917adc6a2b6b166e37fc3d4f94b41488f0c245a5 (diff)
refactor: reorganize files & improve classes
Diffstat (limited to 'src/std/memory.hpp')
-rw-r--r--src/std/memory.hpp33
1 files changed, 33 insertions, 0 deletions
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 <stddef.h>
+
+template <typename memType>
+memType *malloc_s(unsigned int size);
+
+template <class Target>
+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 <typename Target, typename... Args>
+UniquePtr<Target> make_unique(Args... args);
+
+#include "memory.tpp"