diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 744cf8059..e9cc0fa63 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -164,7 +164,7 @@ public: basic_snapshot_loader(registry_type &source) noexcept : reg{&source} { // restoring a snapshot as a whole requires a clean registry - ENTT_ASSERT(reg->template storage().empty() && (reg->storage().begin() == reg->storage().end()), "Registry must be empty"); + ENTT_ASSERT(reg->template storage().free_list() == 0u, "Registry must be empty"); } /*! @brief Default move constructor. */ diff --git a/test/entt/entity/snapshot.cpp b/test/entt/entity/snapshot.cpp index 690840077..48db62f4a 100644 --- a/test/entt/entity/snapshot.cpp +++ b/test/entt/entity/snapshot.cpp @@ -227,6 +227,11 @@ TEST(BasicSnapshotLoader, Constructors) { static_assert(std::is_move_assignable_v>, "Move assignable type required"); entt::registry registry; + + // helps stress the check in the constructor + registry.emplace(registry.create(), 0); + registry.clear(); + entt::basic_snapshot_loader loader{registry}; entt::basic_snapshot_loader other{std::move(loader)};