summaryrefslogtreecommitdiff
path: root/asl/allocator.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-11-19 00:08:33 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-20 15:35:58 +0100
commitd241eaf1b209dcfb05656842dd6250067b704d99 (patch)
tree49f34f6226f4614611d16ba6332b1b50b51a4712 /asl/allocator.hpp
parent58200ce939a591008a8d9406f437252ce2b175cf (diff)
Add allocator, start work on box
Diffstat (limited to 'asl/allocator.hpp')
-rw-r--r--asl/allocator.hpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/asl/allocator.hpp b/asl/allocator.hpp
new file mode 100644
index 0000000..b6c1a9a
--- /dev/null
+++ b/asl/allocator.hpp
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "asl/layout.hpp"
+#include "asl/meta.hpp"
+
+namespace asl
+{
+
+template<typename T>
+concept allocator = requires(T& alloc, layout layout, void* ptr)
+{
+ { alloc.alloc(layout) } -> same_as<void*>;
+ { alloc.realloc(ptr, layout, layout) } -> same_as<void*>;
+ alloc.dealloc(ptr, layout);
+};
+
+class GlobalHeap
+{
+public:
+ static void* alloc(const layout&);
+ static void* realloc(void* ptr, const layout& old, const layout& new_layout);
+ static void dealloc(void* ptr, const layout&);
+};
+static_assert(allocator<GlobalHeap>);
+
+using DefaultAllocator = GlobalHeap;
+
+} // namespace asl