#define RTREE_NO_EXTERN_TEMPLATE_POOL #include "RTree.hpp" //#define RTREE_POOL_DEBUG #ifdef RTREE_POOL_DEBUG #include #include #include #endif namespace floormat::detail { template rtree_pool::rtree_pool() { free_list.reserve(128); } template rtree_pool::~rtree_pool() { for (auto* ptr : free_list) ::operator delete(ptr); free_list.clear(); free_list.shrink_to_fit(); } template T* rtree_pool::construct() { if (free_list.empty()) { #ifdef RTREE_POOL_DEBUG static unsigned i = 0; Debug{} << "rtree-pool: fresh"_s << ++i; std::fflush(stdout); #endif return new T; } else { auto* ret = free_list.back(); free_list.pop_back(); new (ret) T(); #ifdef RTREE_POOL_DEBUG static unsigned i = 0; Debug{} << "rtree-pool: reused"_s << ++i; std::fflush(stdout); #endif return ret; } } template void rtree_pool::free(T* ptr) { ptr->~T(); free_list.push_back(ptr); } using my_rtree = RTree; template<> std::vector rtree_pool::free_list = {}; // NOLINT template<> std::vector rtree_pool::free_list = {}; // NOLINT template struct floormat::detail::rtree_pool; template struct floormat::detail::rtree_pool; } // namespace floormat::detail template class RTree;