diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 6e8125238..76f614ebd 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -100,15 +100,12 @@ struct group_descriptor { } }; -template -class group_handler; - -template -class group_handler, get_t, exclude_t> final: public group_descriptor { +template +class group_handler final: public group_descriptor { using entity_type = typename Type::entity_type; void swap_elements(const std::size_t pos, const entity_type entt) { - for(std::size_t next{}; next < sizeof...(Owned); ++next) { + for(std::size_t next{}; next < Owned; ++next) { pools[next]->swap_elements(pools[next]->data()[pos], entt); } } @@ -139,8 +136,8 @@ public: template group_handler(std::tuple ogpool, std::tuple epool) - : pools{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, ogpool)}, - filter{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, epool)}, + : pools{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, ogpool)}, + filter{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, 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)), ...); }, ogpool); std::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::remove_if>(*this), cpool.on_destroy().template connect<&group_handler::push_on_destroy>(*this)), ...); }, epool); @@ -155,7 +152,7 @@ public: size_type cnt = 0u; for(auto pos = 0u; pos < length; ++pos) { - for(auto next = 0u; next < sizeof...(Owned); ++next) { + for(auto next = 0u; next < Owned; ++next) { cnt += (elem[pos] == pools[next]->type().hash()); } } @@ -169,21 +166,21 @@ public: template [[nodiscard]] common_type *storage() const noexcept { - if constexpr(Index < (sizeof...(Owned) + sizeof...(Get))) { + if constexpr(Index < (Owned + Get)) { return pools[Index]; } else { - return filter[Index - (sizeof...(Owned) + sizeof...(Get))]; + return filter[Index - (Owned + Get)]; } } private: - std::array pools; - std::array filter; + std::array pools; + std::array filter; std::size_t len; }; -template -class group_handler, get_t, exclude_t> final: public group_descriptor { +template +class group_handler final: public group_descriptor { using entity_type = typename Type::entity_type; void push_on_construct(const entity_type entt) { @@ -211,8 +208,8 @@ public: template group_handler(const Alloc &alloc, std::tuple gpool, std::tuple epool) - : pools{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, gpool)}, - filter{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, epool)}, + : pools{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, gpool)}, + filter{std::apply([](auto &&...cpool) { return std::array{&cpool...}; }, epool)}, elem{alloc} { 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)), ...); }, gpool); std::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::remove_if>(*this), cpool.on_destroy().template connect<&group_handler::push_on_destroy>(*this)), ...); }, epool); @@ -232,16 +229,16 @@ public: template [[nodiscard]] common_type *storage() const noexcept { - if constexpr(Index < sizeof...(Get)) { + if constexpr(Index < Get) { return pools[Index]; } else { - return filter[Index - sizeof...(Get)]; + return filter[Index - Get]; } } private: - std::array pools; - std::array filter; + std::array pools; + std::array filter; common_type elem; }; @@ -307,7 +304,7 @@ public: /*! @brief Iterable group type. */ using iterable = iterable_adaptor, get_t>>; /*! @brief Group handler type. */ - using handler = internal::group_handler, get_t...>, exclude_t...>>; + using handler = internal::group_handler; /*! @brief Group opaque marker. */ static constexpr id_type group_id = type_hash, get_t...>, exclude_t...>>>::value(); @@ -717,7 +714,7 @@ public: /*! @brief Iterable group type. */ using iterable = iterable_adaptor, get_t>>; /*! @brief Group handler type. */ - using handler = internal::group_handler...>, get_t...>, exclude_t...>>; + using handler = internal::group_handler; /*! @brief Group opaque marker. */ static constexpr id_type group_id = type_hash...>, get_t...>, exclude_t...>>>::value();