diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 6ce739e80..6e8125238 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -309,6 +309,9 @@ public: /*! @brief Group handler type. */ using handler = internal::group_handler, get_t...>, exclude_t...>>; + /*! @brief Group opaque marker. */ + static constexpr id_type group_id = type_hash, get_t...>, exclude_t...>>>::value(); + /*! @brief Default constructor to use to create empty, invalid groups. */ basic_group() noexcept : descriptor{} {} @@ -716,6 +719,9 @@ public: /*! @brief Group handler type. */ using handler = internal::group_handler...>, get_t...>, exclude_t...>>; + /*! @brief Group opaque marker. */ + static constexpr id_type group_id = type_hash...>, get_t...>, exclude_t...>>>::value(); + /*! @brief Default constructor to use to create empty, invalid groups. */ basic_group() noexcept : descriptor{} {} diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 9f966c8ed..1ea80b3b1 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -1067,9 +1067,10 @@ public: template basic_group...>, get_t...>, exclude_t...>> group(get_t = get_t{}, exclude_t = exclude_t{}) { - using handler_type = typename basic_group...>, get_t...>, exclude_t...>>::handler; + using group_type = basic_group...>, get_t...>, exclude_t...>>; + using handler_type = typename group_type::handler; - if(auto it = groups.find(type_hash::value()); it != groups.cend()) { + if(auto it = groups.find(group_type::group_id); it != groups.cend()) { return {*std::static_pointer_cast(it->second)}; } @@ -1083,7 +1084,7 @@ public: ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [&elem](const auto &data) { return data.second->owned(elem, sizeof...(Owned)) == 0u; }), "Conflicting groups"); } - groups.emplace(type_hash::value(), handler); + groups.emplace(group_type::group_id, handler); return {*handler}; } @@ -1091,9 +1092,10 @@ public: template basic_group...>, get_t...>, exclude_t...>> group_if_exists(get_t = get_t{}, exclude_t = exclude_t{}) const { - using handler_type = typename basic_group...>, get_t...>, exclude_t...>>::handler; + using group_type = basic_group...>, get_t...>, exclude_t...>>; + using handler_type = typename group_type::handler; - if(auto it = groups.find(type_hash::value()); it != groups.cend()) { + if(auto it = groups.find(group_type::group_id); it != groups.cend()) { return {*std::static_pointer_cast(it->second)}; }