#pragma once #include "handle-fwd.hpp" #include "compat/defs.hpp" #include #include namespace floormat::impl_handle { template struct Item { fm_DECLARE_DELETED_COPY_MOVE_ASSIGNMENTS(Item); Item(); ~Item() noexcept; union { char empty = {}; Obj object; }; Handle handle; uint32_t next; }; template class Page { friend struct Handle; std::array, PageSize> storage; BitArray used_map; // todo replace with a rewrite of std::bitset uint32_t start_index; uint32_t used_count; uint32_t first_free; bool locked; static void do_deallocate(Item& item); public: fm_DECLARE_DELETED_COPY_MOVE_ASSIGNMENTS(Page); explicit Page(uint32_t start_index); ~Page() noexcept; template requires requires (Xs&&... xs) { Obj{forward(xs)...}; } [[nodiscard]] Item& allocate(Xs&&... xs); void deallocate(Handle obj); void deallocate_all(); bool is_empty(); bool is_full(); uint32_t use_count() const; }; } // namespace floormat::impl_handle