registry: drop ::assign (deprecated function)

This commit is contained in:
Michele Caini
2023-06-19 10:44:42 +02:00
parent 25a401042a
commit ffdc7893fe
2 changed files with 5 additions and 26 deletions

View File

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

View File

@@ -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]));