diff options
Diffstat (limited to 'src/handle-page.hpp')
-rw-r--r-- | src/handle-page.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/handle-page.hpp b/src/handle-page.hpp index c0397db7..057a512e 100644 --- a/src/handle-page.hpp +++ b/src/handle-page.hpp @@ -9,7 +9,7 @@ namespace floormat::impl_handle { template<typename Obj, uint32_t PageSize> struct Item { - union { Obj object; }; + union { char empty = {}; Obj object; }; Handle<Obj, PageSize> handle; uint32_t next; }; @@ -25,14 +25,21 @@ class Page uint32_t used_count = 0; uint32_t first_free = (uint32_t)-1; + static void do_deallocate(Item<Obj, PageSize>& item); + public: fm_DECLARE_DELETED_COPY_MOVE_ASSIGNMENTS(Page); explicit Page(uint32_t start_index); ~Page() noexcept; - [[nodiscard]] Item<Obj, PageSize>& allocate(); + template<typename... Xs> + requires requires (Xs&&... xs) { + Obj{forward<Xs>(xs)...}; + } + [[nodiscard]] Item<Obj, PageSize>& allocate(Xs&&... xs); void deallocate(Handle<Obj, PageSize> obj); + void deallocate_all(); bool is_empty(); bool is_full(); }; |