diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-03 12:13:34 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-03 12:13:34 +0100 |
commit | 46944ec98688e962e94dcfcf426215f252bf2a87 (patch) | |
tree | 1fb08cbc3cd3dedfe8940dbebe8eb1bf5089ac21 /asl/allocator.hpp | |
parent | c2d4216695b48dfe6bf7083c11e0a7fcbb671e2e (diff) |
Start work on status
Diffstat (limited to 'asl/allocator.hpp')
-rw-r--r-- | asl/allocator.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/asl/allocator.hpp b/asl/allocator.hpp index 5f8f9b6..265378b 100644 --- a/asl/allocator.hpp +++ b/asl/allocator.hpp @@ -2,6 +2,7 @@ #include "asl/layout.hpp"
#include "asl/meta.hpp"
+#include "asl/memory.hpp"
namespace asl
{
@@ -28,4 +29,30 @@ static_assert(allocator<GlobalHeap>); using DefaultAllocator = GlobalHeap;
+template<typename T>
+T* alloc_new(allocator auto& a, auto&&... args)
+{
+ void* ptr = a.alloc(layout::of<T>());
+ return construct_at<T>(ptr, ASL_FWD(args)...);
+}
+
+template<typename T>
+void alloc_delete(allocator auto& a, T* ptr)
+{
+ destroy(ptr);
+ a.dealloc(ptr, layout::of<T>());
+}
+
+template<typename T>
+constexpr T* alloc_new_default(auto&&... args)
+{
+ return alloc_new<T>(DefaultAllocator{}, ASL_FWD(args)...);
+}
+
+template<typename T>
+void alloc_delete_default(T* ptr)
+{
+ alloc_delete(DefaultAllocator{}, ptr);
+}
+
} // namespace asl
|