diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 21d0ea277..7b4b92576 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -2,6 +2,7 @@ #define ENTT_ENTITY_REGISTRY_HPP #include +#include #include #include #include @@ -719,9 +720,9 @@ public: size_type count{}; if constexpr(std::is_same_v) { - common_type *cpools[sizeof...(Other) + 1u]{&assure(), &assure()...}; + std::array cpools{static_cast(&assure()), static_cast(&assure())...}; - for(size_type pos{}, len = sizeof...(Other) + 1u; pos < len; ++pos) { + for(size_type pos{}, len = cpools.size(); pos < len; ++pos) { if constexpr(sizeof...(Other) != 0u) { if(cpools[pos]->data() == first.data()) { std::swap(cpools[pos], cpools[sizeof...(Other)]); @@ -769,9 +770,9 @@ public: template void erase(It first, It last) { if constexpr(std::is_same_v) { - common_type *cpools[sizeof...(Other) + 1u]{&assure(), &assure()...}; + std::array cpools{static_cast(&assure()), static_cast(&assure())...}; - for(size_type pos{}, len = sizeof...(Other) + 1u; pos < len; ++pos) { + for(size_type pos{}, len = cpools.size(); pos < len; ++pos) { if constexpr(sizeof...(Other) != 0u) { if(cpools[pos]->data() == first.data()) { std::swap(cpools[pos], cpools[sizeof...(Other)]); @@ -1085,8 +1086,8 @@ public: handler = std::allocate_shared(get_allocator(), get_allocator(), std::forward_as_tuple(assure>()...), std::forward_as_tuple(assure>()...)); } else { handler = std::allocate_shared(get_allocator(), std::forward_as_tuple(assure>()..., assure>()...), std::forward_as_tuple(assure>()...)); - [[maybe_unused]] const id_type elem[]{type_hash>::value()..., type_hash>::value()..., type_hash>::value()...}; - ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [&elem](const auto &data) { return data.second->owned(elem, sizeof...(Owned)) == 0u; }), "Conflicting groups"); + [[maybe_unused]] const std::array elem{type_hash>::value()..., type_hash>::value()..., type_hash>::value()...}; + ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [&elem](const auto &data) { return data.second->owned(elem.data(), sizeof...(Owned)) == 0u; }), "Conflicting groups"); } groups.emplace(group_type::group_id(), handler); @@ -1116,8 +1117,8 @@ public: */ template [[nodiscard]] bool owned() const { - const id_type elem[]{type_hash>::value(), type_hash>::value()...}; - return std::any_of(groups.cbegin(), groups.cend(), [&elem](auto &&data) { return data.second->owned(elem, 1u + sizeof...(Other)); }); + const std::array elem{type_hash>::value(), type_hash>::value()...}; + return std::any_of(groups.cbegin(), groups.cend(), [&elem](auto &&data) { return data.second->owned(elem.data(), 1u + sizeof...(Other)); }); } /**