diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index afab99bfa..db4b40bc0 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -481,14 +481,6 @@ public: return entities.capacity(); } - /** - * @brief Checks whether the registry is empty (no entities still in use). - * @return True if the registry is empty, false otherwise. - */ - [[deprecated("use .storage().in_use() instead")]] [[nodiscard]] bool empty() const { - return !alive(); - } - /** * @brief Direct access to the list of entities of a registry. * diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 349b27308..f883ec55c 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -172,7 +172,9 @@ public: basic_snapshot_loader(registry_type &source) noexcept : reg{&source} { // restoring a snapshot as a whole requires a clean registry - ENTT_ASSERT(reg->empty(), "Registry must be empty"); + for([[maybe_unused]] auto [id, elem]: source.storage()) { + ENTT_ASSERT(elem.empty(), "Registry must be empty"); + } } /*! @brief Default move constructor. */ diff --git a/test/entt/entity/handle.cpp b/test/entt/entity/handle.cpp index 777be0222..ba33046e0 100644 --- a/test/entt/entity/handle.cpp +++ b/test/entt/entity/handle.cpp @@ -216,7 +216,7 @@ TEST(BasicHandle, Lifetime) { handle->emplace(); ASSERT_FALSE(registry.storage().empty()); - ASSERT_FALSE(registry.empty()); + ASSERT_NE(registry.storage().in_use(), 0u); registry.each([handle](const auto e) { ASSERT_EQ(handle->entity(), e); @@ -225,7 +225,7 @@ TEST(BasicHandle, Lifetime) { delete handle; ASSERT_FALSE(registry.storage().empty()); - ASSERT_FALSE(registry.empty()); + ASSERT_NE(registry.storage().in_use(), 0u); } TEST(BasicHandle, ImplicitConversions) { diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index 32d4f1f6f..50b1b1be9 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -245,7 +245,7 @@ TEST(Registry, Functionalities) { ASSERT_EQ(registry.alive(), 0u); ASSERT_NO_FATAL_FAILURE(registry.reserve(42)); ASSERT_EQ(registry.capacity(), 42u); - ASSERT_TRUE(registry.empty()); + ASSERT_TRUE(registry.storage().empty()); ASSERT_EQ(registry.storage().size(), 0u); ASSERT_EQ(registry.storage().size(), 0u); @@ -325,7 +325,7 @@ TEST(Registry, Functionalities) { ASSERT_EQ(registry.storage().size(), 3u); ASSERT_EQ(registry.alive(), 3u); - ASSERT_FALSE(registry.empty()); + ASSERT_NE(registry.storage().in_use(), 0u); ASSERT_EQ(traits_type::to_version(e2), 0u); ASSERT_EQ(registry.current(e2), 0u); @@ -339,13 +339,14 @@ TEST(Registry, Functionalities) { ASSERT_EQ(registry.storage().size(), 3u); ASSERT_EQ(registry.alive(), 2u); - ASSERT_FALSE(registry.empty()); + ASSERT_NE(registry.storage().in_use(), 0u); ASSERT_NO_FATAL_FAILURE(registry.clear()); ASSERT_EQ(registry.storage().size(), 3u); ASSERT_EQ(registry.alive(), 0u); - ASSERT_TRUE(registry.empty()); + ASSERT_EQ(registry.storage().in_use(), 0u); + ASSERT_FALSE(registry.storage().empty()); const auto e3 = registry.create(); @@ -391,8 +392,8 @@ TEST(Registry, Constructors) { entt::registry registry; entt::registry other{42}; - ASSERT_TRUE(registry.empty()); - ASSERT_TRUE(other.empty()); + ASSERT_TRUE(registry.storage().empty()); + ASSERT_TRUE(other.storage().empty()); ASSERT_EQ(registry.released(), 0u); ASSERT_EQ(other.released(), 0u);