From a141c401f78467bc15f62882fca5d55a007cacbb Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Mon, 17 Feb 2025 00:21:48 +0100 Subject: Reorganize everything --- asl/allocator.hpp | 58 ------------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 asl/allocator.hpp (limited to 'asl/allocator.hpp') diff --git a/asl/allocator.hpp b/asl/allocator.hpp deleted file mode 100644 index 90793dd..0000000 --- a/asl/allocator.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include "asl/layout.hpp" -#include "asl/meta.hpp" -#include "asl/memory.hpp" - -namespace asl -{ - -template -concept allocator = moveable && equality_comparable && - requires(T& alloc, layout layout, void* ptr) - { - { alloc.alloc(layout) } -> same_as; - { alloc.realloc(ptr, layout, layout) } -> same_as; - 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&); - - constexpr bool operator==(const GlobalHeap&) const { return true; } -}; -static_assert(allocator); - -using DefaultAllocator = GlobalHeap; - -template -T* alloc_new(allocator auto& a, auto&&... args) -{ - void* ptr = a.alloc(layout::of()); - return construct_at(ptr, ASL_FWD(args)...); -} - -template -void alloc_delete(allocator auto& a, T* ptr) -{ - destroy(ptr); - a.dealloc(ptr, layout::of()); -} - -template -constexpr T* alloc_new_default(auto&&... args) -{ - return alloc_new(DefaultAllocator{}, ASL_FWD(args)...); -} - -template -void alloc_delete_default(T* ptr) -{ - alloc_delete(DefaultAllocator{}, ptr); -} - -} // namespace asl -- cgit