diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 8c309c471..e22fda308 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -746,7 +746,7 @@ public: template void remove_if_exists(const entity_type entity) { ENTT_ASSERT(valid(entity)); - ([this, entity]() { if(auto &cpool = assure(); cpool.has(entity)) { cpool.remove(*this, entity); } }(), ...); + ([this, entity](auto &&cpool) { if(cpool.has(entity)) { cpool.remove(*this, entity); } }(assure()), ...); } /**