storage: drop deprecated functions

This commit is contained in:
Michele Caini
2025-03-20 09:20:44 +01:00
parent fa6fdc4059
commit 5ccb46383c
2 changed files with 31 additions and 63 deletions

View File

@@ -1175,27 +1175,6 @@ public:
}
}
/**
* @brief Creates a new identifier or recycles a destroyed one.
* @return A valid identifier.
*/
[[deprecated("use ::generate() instead")]] entity_type emplace() {
return generate();
}
/**
* @brief Creates a new identifier or recycles a destroyed one.
*
* If the requested identifier isn't in use, the suggested one is used.
* Otherwise, a new identifier is returned.
*
* @param hint Required identifier.
* @return A valid identifier.
*/
[[deprecated("use ::generate(hint) instead")]] entity_type emplace(const entity_type hint) {
return generate(hint);
}
/**
* @brief Updates a given identifier.
* @tparam Func Types of the function objects to invoke.
@@ -1208,17 +1187,6 @@ public:
(std::forward<Func>(func)(), ...);
}
/**
* @brief Assigns each element in a range an identifier.
* @tparam It Type of mutable forward iterator.
* @param first An iterator to the first element of the range to generate.
* @param last An iterator past the last element of the range to generate.
*/
template<typename It>
[[deprecated("use ::generate(first, last) instead")]] void insert(It first, It last) {
generate(std::move(first), std::move(last));
}
/**
* @brief Returns an iterable object to use to _visit_ a storage.
*

View File

@@ -143,10 +143,10 @@ TEST(StorageEntity, Generate) {
entt::storage<entt::entity> pool;
std::array<entt::entity, 2u> entity{};
ASSERT_EQ(pool.emplace(), entt::entity{0});
ASSERT_EQ(pool.generate(), entt::entity{0});
ASSERT_EQ(pool.generate(entt::null), entt::entity{1});
ASSERT_EQ(pool.generate(entt::tombstone), entt::entity{2});
ASSERT_EQ(pool.emplace(entt::entity{0}), entt::entity{3});
ASSERT_EQ(pool.generate(entt::entity{0}), entt::entity{3});
ASSERT_EQ(pool.generate(traits_type::construct(1, 1)), entt::entity{4});
ASSERT_EQ(pool.generate(traits_type::construct(6, 3)), traits_type::construct(6, 3));
@@ -172,6 +172,35 @@ TEST(StorageEntity, Generate) {
ASSERT_EQ(entity[1u], entt::entity{8});
}
TEST(StorageEntity, GenerateRange) {
entt::storage<entt::entity> pool;
std::array<entt::entity, 2u> entity{};
pool.generate(entity.begin(), entity.end());
ASSERT_TRUE(pool.contains(entity[0u]));
ASSERT_TRUE(pool.contains(entity[1u]));
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.free_list(), 2u);
pool.erase(entity.begin(), entity.end());
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.free_list(), 0u);
pool.generate(entity.begin(), entity.begin() + 1u);
ASSERT_TRUE(pool.contains(entity[0u]));
ASSERT_FALSE(pool.contains(entity[1u]));
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.free_list(), 1u);
}
TEST(StorageEntity, GenerateFrom) {
entt::storage<entt::entity> pool;
std::array entity{entt::entity{0}, entt::entity{1}, entt::entity{2}};
@@ -287,35 +316,6 @@ ENTT_DEBUG_TEST(StorageEntityDeathTest, Patch) {
ASSERT_DEATH(pool.patch(entt::null), "");
}
TEST(StorageEntity, Insert) {
entt::storage<entt::entity> pool;
std::array<entt::entity, 2u> entity{};
pool.insert(entity.begin(), entity.end());
ASSERT_TRUE(pool.contains(entity[0u]));
ASSERT_TRUE(pool.contains(entity[1u]));
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.free_list(), 2u);
pool.erase(entity.begin(), entity.end());
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.free_list(), 0u);
pool.generate(entity.begin(), entity.begin() + 1u);
ASSERT_TRUE(pool.contains(entity[0u]));
ASSERT_FALSE(pool.contains(entity[1u]));
ASSERT_FALSE(pool.empty());
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(pool.free_list(), 1u);
}
TEST(StorageEntity, Pack) {
entt::storage<entt::entity> pool;
std::array entity{entt::entity{1}, entt::entity{3}, entt::entity{4}, entt::entity{2}};