Răsfoiți Sursa

registry: drop ::size (deprecated function)

Michele Caini 2 ani în urmă
părinte
comite
d7d0ba498c

+ 0 - 8
src/entt/entity/registry.hpp

@@ -456,14 +456,6 @@ public:
         return assure<Type>(id);
     }
 
-    /**
-     * @brief Returns the number of entities created so far.
-     * @return Number of entities created so far.
-     */
-    [[deprecated("use .storage<Entity>().size() instead")]] [[nodiscard]] size_type size() const noexcept {
-        return entities.size();
-    }
-
     /**
      * @brief Returns the number of entities still in use.
      * @return Number of entities still in use.

+ 6 - 6
test/entt/entity/registry.cpp

@@ -241,7 +241,7 @@ TEST(Registry, Functionalities) {
 
     ASSERT_NO_FATAL_FAILURE([[maybe_unused]] auto alloc = registry.get_allocator());
 
-    ASSERT_EQ(registry.size(), 0u);
+    ASSERT_EQ(registry.storage<entt::entity>().size(), 0u);
     ASSERT_EQ(registry.alive(), 0u);
     ASSERT_NO_FATAL_FAILURE(registry.reserve(42));
     ASSERT_EQ(registry.capacity(), 42u);
@@ -323,7 +323,7 @@ TEST(Registry, Functionalities) {
     ASSERT_EQ(static_cast<const entt::registry &>(registry).get<int>(e0), 1);
     ASSERT_EQ(static_cast<const entt::registry &>(registry).get<int>(e1), 1);
 
-    ASSERT_EQ(registry.size(), 3u);
+    ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
     ASSERT_EQ(registry.alive(), 3u);
     ASSERT_FALSE(registry.empty());
 
@@ -337,13 +337,13 @@ TEST(Registry, Functionalities) {
     ASSERT_TRUE(registry.valid(e1));
     ASSERT_FALSE(registry.valid(e2));
 
-    ASSERT_EQ(registry.size(), 3u);
+    ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
     ASSERT_EQ(registry.alive(), 2u);
     ASSERT_FALSE(registry.empty());
 
     ASSERT_NO_FATAL_FAILURE(registry.clear());
 
-    ASSERT_EQ(registry.size(), 3u);
+    ASSERT_EQ(registry.storage<entt::entity>().size(), 3u);
     ASSERT_EQ(registry.alive(), 0u);
     ASSERT_TRUE(registry.empty());
 
@@ -2123,9 +2123,9 @@ TEST(Registry, AssignEntities) {
 
     entt::registry other;
     const auto *data = registry.data();
-    other.assign(data, data + registry.size(), registry.released());
+    other.assign(data, data + registry.storage<entt::entity>().size(), registry.released());
 
-    ASSERT_EQ(registry.size(), other.size());
+    ASSERT_EQ(registry.storage<entt::entity>().size(), other.storage<entt::entity>().size());
     ASSERT_TRUE(other.valid(entities[0]));
     ASSERT_FALSE(other.valid(entities[1]));
     ASSERT_FALSE(other.valid(entities[2]));

+ 6 - 6
test/example/entity_copy.cpp

@@ -57,7 +57,7 @@ TEST(EntityCopy, SameRegistry) {
     registry.emplace<int>(src, 42);
     registry.emplace<char>(src, 'c');
 
-    ASSERT_EQ(registry.size(), 2u);
+    ASSERT_EQ(registry.storage<entt::entity>().size(), 2u);
     ASSERT_TRUE(custom.contains(src));
     ASSERT_FALSE(custom.contains(dst));
     ASSERT_TRUE((registry.all_of<int, char>(src)));
@@ -70,7 +70,7 @@ TEST(EntityCopy, SameRegistry) {
         }
     }
 
-    ASSERT_EQ(registry.size(), 2u);
+    ASSERT_EQ(registry.storage<entt::entity>().size(), 2u);
     ASSERT_TRUE(custom.contains(src));
     ASSERT_FALSE(custom.contains(dst));
     ASSERT_TRUE((registry.all_of<int, char>(src)));
@@ -93,8 +93,8 @@ TYPED_TEST(EntityCopy, CrossRegistry) {
     src.emplace<int>(entity, 42);
     src.emplace<char>(entity, 'c');
 
-    ASSERT_EQ(src.size(), 1u);
-    ASSERT_EQ(dst.size(), 1u);
+    ASSERT_EQ(src.storage<entt::entity>().size(), 1u);
+    ASSERT_EQ(dst.template storage<typename TestFixture::type::entity_type>().size(), 1u);
 
     ASSERT_TRUE((src.all_of<int, char>(entity)));
     ASSERT_FALSE((dst.template all_of<int, char>(copy)));
@@ -113,8 +113,8 @@ TYPED_TEST(EntityCopy, CrossRegistry) {
         }
     }
 
-    ASSERT_EQ(src.size(), 1u);
-    ASSERT_EQ(dst.size(), 1u);
+    ASSERT_EQ(src.storage<entt::entity>().size(), 1u);
+    ASSERT_EQ(dst.template storage<typename TestFixture::type::entity_type>().size(), 1u);
 
     ASSERT_TRUE((src.all_of<int, char>(entity)));
     ASSERT_TRUE((dst.template all_of<int, char>(copy)));

+ 1 - 1
test/lib/registry/plugin/main.cpp

@@ -19,7 +19,7 @@ TEST(Lib, Registry) {
     cr_plugin_update(ctx);
 
     ASSERT_EQ(registry.storage<position>().size(), registry.storage<velocity>().size());
-    ASSERT_EQ(registry.storage<position>().size(), registry.size());
+    ASSERT_EQ(registry.storage<position>().size(), registry.storage<entt::entity>().size());
 
     registry.view<position>().each([](auto entity, auto &position) {
         ASSERT_EQ(position.x, static_cast<int>(entt::to_integral(entity) + 16u));