diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 76c3dd46d..ec49e3867 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -200,7 +200,7 @@ class basic_registry { struct pool_data { std::unique_ptr> pool; std::unique_ptr> (* clone)(const sparse_set &); - delegate remove; + void (* remove)(sparse_set &, basic_registry &, const Entity); ENTT_ID_TYPE runtime_type; }; @@ -280,7 +280,10 @@ class basic_registry { if(!pdata->pool) { pdata->runtime_type = ctype; pdata->pool = std::make_unique>(); - pdata->remove.template connect<&pool_type::remove>(static_cast *>(pdata->pool.get())); + + pdata->remove = [](sparse_set &other, basic_registry ®istry, const Entity entt) { + static_cast &>(other).remove(registry, entt); + }; pdata->clone = [](const sparse_set &other) -> std::unique_ptr> { if constexpr(std::is_copy_constructible_v>) { @@ -644,7 +647,7 @@ public: for(auto pos = pools.size(); pos; --pos) { if(auto &pdata = pools[pos-1]; pdata.pool && pdata.pool->has(entity)) { - pdata.remove(*this, entity); + pdata.remove(*pdata.pool, *this, entity); } }; @@ -1468,7 +1471,8 @@ public: if(auto &pdata = pools[pos-1]; pdata.pool && (!sizeof...(Component) || ... || (pdata.runtime_type == type()))) { auto &curr = other.pools[pos-1]; curr.clone = pdata.clone; - curr.pool = curr.clone(*pdata.pool); + curr.remove = pdata.remove; + curr.pool = pdata.clone(*pdata.pool); curr.runtime_type = pdata.runtime_type; ENTT_ASSERT(sizeof...(Component) == 0 || curr.pool); } diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index be3972bb3..11b3a9555 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -1303,6 +1303,9 @@ TEST(Registry, Clone) { ASSERT_TRUE(other.orphan(e0)); ASSERT_EQ(other.get(e2), '2'); + + // the remove erased function must be available after cloning + other.reset(); } TEST(Registry, CloneMoveOnlyComponent) {