diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 3e3df2c85..bc8a3f720 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -1351,8 +1351,7 @@ public: // we cannot iterate backwards because we want to leave behind valid entities in case of owned types std::for_each(std::make_reverse_iterator(cpool.end()), std::make_reverse_iterator(cpool.begin()), [cpools, handler, curr = view(entt::exclude)](const auto entity) { - if(curr.contains(entity) && !(std::get<0>(cpools).index(entity) < handler->current)) { - const auto pos = handler->current++; + if(const auto pos = handler->current; curr.contains(entity) && !(std::get<0>(cpools).index(entity) < ++handler->current)) { (std::get> &>(cpools).swap(std::get> &>(cpools).data()[pos], entity), ...); } });