diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 348009ad0..b09aa24ab 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -95,13 +95,9 @@ template struct owning_group_descriptor { using size_type = std::size_t; - owning_group_descriptor(const size_type sz) - : size{sz} {} - virtual ~owning_group_descriptor() = default; virtual size_type check(const id_type *, const size_type, const size_type, const size_type) const noexcept = 0; - - const size_type size; + virtual size_type size() const noexcept = 0; }; template @@ -144,8 +140,7 @@ public: using size_type = typename owning_group_descriptor::size_type; group_handler(Owned &...opool, Get &...gpool, Exclude &...epool) - : owning_group_descriptor{sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude)}, - pools{&opool..., &gpool...}, + : pools{&opool..., &gpool...}, filter{&epool...}, len{} { std::apply([this](auto *...cpool) { ((cpool->on_construct().template connect<&group_handler::push_on_construct>(*this), cpool->on_destroy().template connect<&group_handler::remove_if>(*this)), ...); }, pools); @@ -175,6 +170,10 @@ public: return cnt; } + size_type size() const noexcept final { + return sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude); + } + void previous(const owning_group_descriptor &elem) { std::apply([this, &elem](auto *...cpool) { ((cpool->on_destroy().disconnect(this), cpool->on_destroy().before(&elem).template connect<&group_handler::remove_if>(*this)), ...); }, pools); std::apply([this, &elem](auto *...cpool) { ((cpool->on_construct().disconnect(this), cpool->on_construct().before(&elem).template connect<&group_handler::remove_if>(*this)), ...); }, filter); diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index fd1c23e28..1a548b0c2 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -1226,10 +1226,10 @@ public: auto handler = std::allocate_shared(get_allocator(), assure>()..., assure>()..., assure>()...); owning_groups.emplace(type_hash::value(), handler); - ENTT_ASSERT(std::all_of(owning_groups.cbegin(), owning_groups.cend(), [&elem, hsize = handler->size](const auto &data) { + ENTT_ASSERT(std::all_of(owning_groups.cbegin(), owning_groups.cend(), [&elem, hsize = handler->size()](const auto &data) { const auto overlapping = data.second->check(elem, sizeof...(Owned), 0u, 0u); const auto sz = data.second->check(elem, sizeof...(Owned), sizeof...(Get), sizeof...(Exclude)); - return !overlapping || ((sz == hsize) || (sz == data.second->size)); + return !overlapping || ((sz == hsize) || (sz == data.second->size())); }), "Conflicting groups"); @@ -1237,12 +1237,12 @@ public: const internal::owning_group_descriptor *next = nullptr; for(auto &&data: owning_groups) { - if(data.second->check(elem, sizeof...(Owned), 0u, 0u)) { - if(const auto sz = data.second->size; sz < handler->size && (prev == nullptr || prev->size < sz)) { + if(const auto sz = data.second->size(); data.second->check(elem, sizeof...(Owned), 0u, 0u)) { + if(sz < handler->size() && (prev == nullptr || prev->size() < sz)) { prev = data.second.get(); } - if(const auto sz = data.second->size; sz > handler->size && (next == nullptr || next->size > sz)) { + if(sz > handler->size() && (next == nullptr || next->size() > sz)) { next = data.second.get(); } } @@ -1303,7 +1303,7 @@ public: [[nodiscard]] bool sortable(const basic_group, get_t, exclude_t> &) noexcept { constexpr auto size = sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude); const id_type elem[]{type_hash::value()...}; - auto pred = [&elem, size](const auto &data) { return data.second->check(elem, sizeof...(Owned), 0u, 0u) && (size < data.second->size); }; + auto pred = [&elem, size](const auto &data) { return data.second->check(elem, sizeof...(Owned), 0u, 0u) && (size < data.second->size()); }; return std::find_if(owning_groups.cbegin(), owning_groups.cend(), std::move(pred)) == owning_groups.cend(); }