| HPool is a lightweight pool allocator supporting multiple types and dynamic extension. |
The recommended way (for now) is using git submodules. If you want to integrate HPool into your project, add it as a submodule.
To build tests, you need GTest available globally.
cmake -S. -Bbuild
cmake --build build --target tests
build/testsCreate pool object. If you want a single-type pool:
// Create a pool, that holds 32 ints.
HPool::HPool<int> pool(32);If you want a multi-type pool:
// Create a combined pool, that can hold 32 objects of either int or string.
HPool::HPool<int, std::string> pool(32);auto ptr = pool.allocate();For single-type pool, ptr has type HPool::Ptr<int>.
For multi-type pool, ptr has type HPool::Ptr<int, std::variant<int, std::string>>.
pool.free(ptr);uint32_t count = pool.size();uint32_t count = pool.allocated();