registry: drop ::each (deprecated function)
This commit is contained in:
@@ -1046,27 +1046,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Iterates all the entities that are still in use.
|
||||
*
|
||||
* The signature of the function should be equivalent to the following:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* void(const Entity);
|
||||
* @endcode
|
||||
*
|
||||
* It's not defined whether entities created during iteration are returned.
|
||||
*
|
||||
* @tparam Func Type of the function object to invoke.
|
||||
* @param func A valid function object.
|
||||
*/
|
||||
template<typename Func>
|
||||
[[deprecated("use .storage<Entity>().each() instead")]] void each(Func func) const {
|
||||
for(auto [entt]: entities.each()) {
|
||||
func(entt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if an entity has components assigned.
|
||||
* @param entt A valid identifier.
|
||||
|
||||
@@ -63,23 +63,25 @@ void pathological_with(Func func) {
|
||||
}
|
||||
|
||||
for(auto i = 0; i < 10; ++i) {
|
||||
registry.each([i = 0, ®istry](const auto entity) mutable {
|
||||
if(!(++i % 7)) {
|
||||
auto curr = 0;
|
||||
|
||||
for(auto [entity]: registry.storage<entt::entity>().each()) {
|
||||
if(!(++curr % 7)) {
|
||||
registry.remove<position>(entity);
|
||||
}
|
||||
|
||||
if(!(++i % 11)) {
|
||||
if(!(++curr % 11)) {
|
||||
registry.remove<velocity>(entity);
|
||||
}
|
||||
|
||||
if(!(++i % 13)) {
|
||||
if(!(++curr % 13)) {
|
||||
registry.remove<comp<0>>(entity);
|
||||
}
|
||||
|
||||
if(!(++i % 17)) {
|
||||
if(!(++curr % 17)) {
|
||||
registry.destroy(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for(std::uint64_t j = 0; j < 50000L; j++) {
|
||||
const auto entity = registry.create();
|
||||
|
||||
@@ -218,9 +218,9 @@ TEST(BasicHandle, Lifetime) {
|
||||
ASSERT_FALSE(registry.storage<int>().empty());
|
||||
ASSERT_NE(registry.storage<entt::entity>().in_use(), 0u);
|
||||
|
||||
registry.each([handle](const auto e) {
|
||||
ASSERT_EQ(handle->entity(), e);
|
||||
});
|
||||
for(auto [entt]: registry.storage<entt::entity>().each()) {
|
||||
ASSERT_EQ(handle->entity(), entt);
|
||||
}
|
||||
|
||||
delete handle;
|
||||
|
||||
|
||||
@@ -648,7 +648,7 @@ TEST(Registry, CreateDestroyReleaseCornerCase) {
|
||||
registry.destroy(e0);
|
||||
registry.release(e1);
|
||||
|
||||
registry.each([](auto) { FAIL(); });
|
||||
ASSERT_EQ(registry.storage<entt::entity>().in_use(), 0u);
|
||||
|
||||
ASSERT_EQ(registry.current(e0), 1u);
|
||||
ASSERT_EQ(registry.current(e1), 1u);
|
||||
@@ -895,59 +895,6 @@ TEST(Registry, TombstoneVersion) {
|
||||
ASSERT_NE(registry.create(required), required);
|
||||
}
|
||||
|
||||
TEST(Registry, Each) {
|
||||
entt::registry registry;
|
||||
entt::registry::size_type tot;
|
||||
entt::registry::size_type match;
|
||||
|
||||
static_cast<void>(registry.create());
|
||||
registry.emplace<int>(registry.create());
|
||||
static_cast<void>(registry.create());
|
||||
registry.emplace<int>(registry.create());
|
||||
static_cast<void>(registry.create());
|
||||
|
||||
tot = 0u;
|
||||
match = 0u;
|
||||
|
||||
registry.each([&](auto entity) {
|
||||
match += registry.all_of<int>(entity);
|
||||
static_cast<void>(registry.create());
|
||||
++tot;
|
||||
});
|
||||
|
||||
ASSERT_EQ(tot, 5u);
|
||||
ASSERT_EQ(match, 2u);
|
||||
|
||||
tot = 0u;
|
||||
match = 0u;
|
||||
|
||||
registry.each([&](auto entity) {
|
||||
if(registry.all_of<int>(entity)) {
|
||||
registry.destroy(entity);
|
||||
++match;
|
||||
}
|
||||
|
||||
++tot;
|
||||
});
|
||||
|
||||
ASSERT_EQ(tot, 10u);
|
||||
ASSERT_EQ(match, 2u);
|
||||
|
||||
tot = 0u;
|
||||
match = 0u;
|
||||
|
||||
registry.each([&](auto entity) {
|
||||
match += registry.all_of<int>(entity);
|
||||
registry.destroy(entity);
|
||||
++tot;
|
||||
});
|
||||
|
||||
ASSERT_EQ(tot, 8u);
|
||||
ASSERT_EQ(match, 0u);
|
||||
|
||||
registry.each([&](auto) { FAIL(); });
|
||||
}
|
||||
|
||||
TEST(Registry, Orphans) {
|
||||
entt::registry registry;
|
||||
entt::entity entities[3u]{};
|
||||
@@ -956,16 +903,16 @@ TEST(Registry, Orphans) {
|
||||
registry.emplace<int>(entities[0u]);
|
||||
registry.emplace<int>(entities[2u]);
|
||||
|
||||
registry.each([&](const auto entt) {
|
||||
for(auto [entt]: registry.storage<entt::entity>().each()) {
|
||||
ASSERT_TRUE(entt != entities[1u] || registry.orphan(entt));
|
||||
});
|
||||
}
|
||||
|
||||
registry.erase<int>(entities[0u]);
|
||||
registry.erase<int>(entities[2u]);
|
||||
|
||||
registry.each([&](const auto entt) {
|
||||
for(auto [entt]: registry.storage<entt::entity>().each()) {
|
||||
ASSERT_TRUE(registry.orphan(entt));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Registry, View) {
|
||||
|
||||
Reference in New Issue
Block a user