registry: review remove/erase to use iterators

This commit is contained in:
Michele Caini
2024-06-06 10:58:17 +02:00
parent 47d71fa6cf
commit 8062bcfb3c

View File

@@ -734,15 +734,16 @@ public:
if constexpr(std::is_same_v<It, typename common_type::iterator>) {
std::array cpools{static_cast<common_type *>(&assure<Type>()), static_cast<common_type *>(&assure<Other>())...};
for(size_type pos{}, len = cpools.size(); pos < len; ++pos) {
for(auto from = cpools.begin(), to = cpools.end(); from != to; ++from) {
if constexpr(sizeof...(Other) != 0u) {
if(cpools[pos]->data() == first.data()) {
std::swap(cpools[pos], cpools[sizeof...(Other)]);
if((*from)->data() == first.data()) {
std::swap((*from), cpools.back());
}
}
count += cpools[pos]->remove(first, last);
count += (*from)->remove(first, last);
}
} else {
for(auto cpools = std::forward_as_tuple(assure<Type>(), assure<Other>()...); first != last; ++first) {
count += std::apply([entt = *first](auto &...curr) { return (curr.remove(entt) + ... + 0u); }, cpools);
@@ -784,14 +785,14 @@ public:
if constexpr(std::is_same_v<It, typename common_type::iterator>) {
std::array cpools{static_cast<common_type *>(&assure<Type>()), static_cast<common_type *>(&assure<Other>())...};
for(size_type pos{}, len = cpools.size(); pos < len; ++pos) {
for(auto from = cpools.begin(), to = cpools.end(); from != to; ++from) {
if constexpr(sizeof...(Other) != 0u) {
if(cpools[pos]->data() == first.data()) {
std::swap(cpools[pos], cpools[sizeof...(Other)]);
if((*from)->data() == first.data()) {
std::swap(*from, cpools.back());
}
}
cpools[pos]->erase(first, last);
(*from)->erase(first, last);
}
} else {
for(auto cpools = std::forward_as_tuple(assure<Type>(), assure<Other>()...); first != last; ++first) {