diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 4b71c1008..95f9b36d3 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -668,7 +668,7 @@ public: /*! @copydoc begin Useful only in case of swap-only policy. */ [[nodiscard]] iterator begin(int) const noexcept { - return begin() + static_cast((size() - static_cast(head)) * (mode == deletion_policy::swap_only)); + return (mode == deletion_policy::swap_only) ? (end() - static_cast(head)) : begin(); } /*! @copydoc cbegin Useful only in case of swap-only policy. */