diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 06824a43a..4d8b958dc 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -165,10 +165,10 @@ class basic_group, get_t> final { template void traverse(Func func, type_list) const { for(const auto entt: *handler) { - if constexpr(std::is_invocable_v({}))...>) { - func(std::get *>(pools)->get(entt)...); - } else { + if constexpr(std::is_invocable_v({}))...>) { func(entt, std::get *>(pools)->get(entt)...); + } else { + func(std::get *>(pools)->get(entt)...); } } } @@ -743,16 +743,14 @@ class basic_group, get_t, Owned...> final [[maybe_unused]] auto data = std::get<0>(pools)->basic_sparse_set::end() - *length; for(auto next = *length; next; --next) { - if constexpr(std::is_invocable_v({}))..., decltype(get({}))...>) { - if constexpr(sizeof...(Weak) == 0) { - func(*(std::get>(it)++)...); - } else { - const auto entt = *(data++); - func(*(std::get>(it)++)..., std::get *>(pools)->get(entt)...); - } - } else { + if constexpr(std::is_invocable_v({}))..., decltype(get({}))...>) { const auto entt = *(data++); func(entt, *(std::get>(it)++)..., std::get *>(pools)->get(entt)...); + } else if constexpr(sizeof...(Weak) == 0) { + func(*(std::get>(it)++)...); + } else { + const auto entt = *(data++); + func(*(std::get>(it)++)..., std::get *>(pools)->get(entt)...); } } } diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index c1ff3977e..4c65ef7ce 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -275,10 +275,10 @@ class basic_view, Component...> final { if(((std::is_same_v || std::get *>(pools)->contains(entt)) && ...) && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const basic_sparse_set *cpool) { return cpool->contains(entt); }))) { - if constexpr(std::is_invocable_v({}))...>) { - func(get(it, std::get *>(pools), entt)...); - } else { + if constexpr(std::is_invocable_v({}))...>) { func(entt, get(it, std::get *>(pools), entt)...); + } else { + func(get(it, std::get *>(pools), entt)...); } } @@ -289,10 +289,10 @@ class basic_view, Component...> final { if(((std::is_same_v || std::get *>(pools)->contains(entt)) && ...) && (sizeof...(Exclude) == 0 || std::none_of(filter.cbegin(), filter.cend(), [entt](const basic_sparse_set *cpool) { return cpool->contains(entt); }))) { - if constexpr(std::is_invocable_v({}))...>) { - func(std::get *>(pools)->get(entt)...); - } else { + if constexpr(std::is_invocable_v({}))...>) { func(entt, std::get *>(pools)->get(entt)...); + } else { + func(std::get *>(pools)->get(entt)...); } } } @@ -952,26 +952,26 @@ public: template void each(Func func) const { if constexpr(is_eto_eligible_v) { - if constexpr(std::is_invocable_v) { - for(auto pos = pool->size(); pos; --pos) { - func(); - } - } else { + if constexpr(std::is_invocable_v) { for(const auto entt: *this) { func(entt); } + } else { + for(auto pos = pool->size(); pos; --pos) { + func(); + } } } else { - if constexpr(std::is_invocable_v>) { - for(auto &&component: *pool) { - func(component); - } - } else { + if constexpr(std::is_invocable_v>) { auto raw = pool->begin(); for(const auto entt: *this) { func(entt, *(raw++)); } + } else { + for(auto &&component: *pool) { + func(component); + } } } }