فهرست منبع

registry: drop ::assign (deprecated function)

Michele Caini 2 سال پیش
والد
کامیت
ffdc7893fe
2فایلهای تغییر یافته به همراه5 افزوده شده و 26 حذف شده
  1. 0 24
      src/entt/entity/registry.hpp
  2. 5 2
      test/entt/entity/registry.cpp

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

@@ -510,30 +510,6 @@ public:
         entities.insert(std::move(first), std::move(last));
     }
 
-    /**
-     * @brief Assigns identifiers to an empty registry.
-     *
-     * This function is intended for use in conjunction with `data`, `size` and
-     * `released`.<br/>
-     * Don't try to inject ranges of randomly generated entities nor the _wrong_
-     * head for the list of destroyed entities. There is no guarantee that a
-     * registry will continue to work properly in this case.
-     *
-     * @warning
-     * There must be no entities still alive for this to work properly.
-     *
-     * @tparam It Type of input iterator.
-     * @param first An iterator to the first element of the range of entities.
-     * @param last An iterator past the last element of the range of entities.
-     * @param destroyed The number of released entities.
-     */
-    template<typename It>
-    [[deprecated("use .storage<Entity>().push(first, last) and .storage<Entity>().in_use(len) instead")]] void assign(It first, It last, const size_type destroyed) {
-        ENTT_ASSERT(!entities.in_use(), "Non-empty registry");
-        entities.push(first, last);
-        entities.in_use(entities.size() - destroyed);
-    }
-
     /**
      * @brief Destroys an entity and releases its identifier.
      *

+ 5 - 2
test/entt/entity/registry.cpp

@@ -2002,8 +2002,11 @@ TEST(Registry, AssignEntities) {
     registry.destroy(entities[2]);
 
     entt::registry other;
-    const auto *data = registry.storage<entt::entity>().data();
-    other.assign(data, data + registry.storage<entt::entity>().size(), registry.storage<entt::entity>().size() - registry.storage<entt::entity>().in_use());
+    auto &src = registry.storage<entt::entity>();
+    auto &dst = other.storage<entt::entity>();
+
+    dst.push(src.rbegin(), src.rend());
+    dst.in_use(src.in_use());
 
     ASSERT_EQ(registry.storage<entt::entity>().size(), other.storage<entt::entity>().size());
     ASSERT_TRUE(other.valid(entities[0]));