registry: drop ::empty (deprecated function)

This commit is contained in:
Michele Caini
2023-06-16 11:18:10 +02:00
parent d7d0ba498c
commit 57d8072901
4 changed files with 12 additions and 17 deletions

View File

@@ -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<Entity>().in_use() instead")]] [[nodiscard]] bool empty() const {
return !alive();
}
/**
* @brief Direct access to the list of entities of a registry.
*

View File

@@ -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. */

View File

@@ -216,7 +216,7 @@ TEST(BasicHandle, Lifetime) {
handle->emplace<int>();
ASSERT_FALSE(registry.storage<int>().empty());
ASSERT_FALSE(registry.empty());
ASSERT_NE(registry.storage<entt::entity>().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<int>().empty());
ASSERT_FALSE(registry.empty());
ASSERT_NE(registry.storage<entt::entity>().in_use(), 0u);
}
TEST(BasicHandle, ImplicitConversions) {

View File

@@ -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<entt::entity>().empty());
ASSERT_EQ(registry.storage<int>().size(), 0u);
ASSERT_EQ(registry.storage<char>().size(), 0u);
@@ -325,7 +325,7 @@ TEST(Registry, Functionalities) {
ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
ASSERT_EQ(registry.alive(), 3u);
ASSERT_FALSE(registry.empty());
ASSERT_NE(registry.storage<entt::entity>().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<entt::entity>().size(), 3u);
ASSERT_EQ(registry.alive(), 2u);
ASSERT_FALSE(registry.empty());
ASSERT_NE(registry.storage<entt::entity>().in_use(), 0u);
ASSERT_NO_FATAL_FAILURE(registry.clear());
ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
ASSERT_EQ(registry.alive(), 0u);
ASSERT_TRUE(registry.empty());
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 0u);
ASSERT_FALSE(registry.storage<entt::entity>().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<entt::entity>().empty());
ASSERT_TRUE(other.storage<entt::entity>().empty());
ASSERT_EQ(registry.released(), 0u);
ASSERT_EQ(other.released(), 0u);