diff --git a/src/entt/entity/mixin.hpp b/src/entt/entity/mixin.hpp index d02d65fa2..74e523f8a 100644 --- a/src/entt/entity/mixin.hpp +++ b/src/entt/entity/mixin.hpp @@ -58,16 +58,18 @@ private: void pop_all() final { if(auto ® = owner_or_assert(); !destruction.empty()) { - for(auto it = underlying_type::base_type::begin(0), last = underlying_type::base_type::end(0); it != last; ++it) { - if constexpr(std::is_same_v) { - destruction.publish(reg, *it); - } else { + if constexpr(std::is_same_v) { + for(typename Type::size_type pos{}, last = Type::free_list(); pos < last; ++pos) { + destruction.publish(reg, underlying_type::base_type::operator[](pos)); + } + } else { + for(auto entt: static_cast(*this)) { if constexpr(component_traits::in_place_delete) { - if(const auto entt = *it; entt != tombstone) { + if(entt != tombstone) { destruction.publish(reg, entt); } } else { - destruction.publish(reg, *it); + destruction.publish(reg, entt); } } }