diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index db913752e..6be4b3978 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -200,7 +200,9 @@ class basic_registry { struct group_data { const std::size_t extent[3]; std::unique_ptr group; - bool(* const is_same)(const component *) ENTT_NOEXCEPT; + bool(* const owned)(const component) ENTT_NOEXCEPT; + bool(* const get)(const component) ENTT_NOEXCEPT; + bool(* const exclude)(const component) ENTT_NOEXCEPT; }; struct ctx_variable { @@ -1363,13 +1365,14 @@ public: static_assert(sizeof...(Owned) + sizeof...(Get) + sizeof...(Exclude) > 1); using handler_type = group_handler, get_t, Owned...>; - - const std::size_t extent[] = { sizeof...(Owned), sizeof...(Get), sizeof...(Exclude) }; - const component types[] = { type()..., type()..., type()... }; + const std::size_t extent[3]{sizeof...(Owned), sizeof...(Get), sizeof...(Exclude)}; handler_type *curr = nullptr; - if(auto it = std::find_if(groups.begin(), groups.end(), [&extent, &types](auto &&gdata) { - return std::equal(std::begin(extent), std::end(extent), gdata.extent) && gdata.is_same(types); + if(auto it = std::find_if(groups.cbegin(), groups.cend(), [&extent](const auto &gdata) { + return std::equal(std::begin(extent), std::end(extent), std::begin(gdata.extent)) + && (gdata.owned(type()) && ...) + && (gdata.get(type()) && ...) + && (gdata.exclude(type()) && ...); }); it != groups.cend()) { curr = static_cast(it->group.get()); @@ -1379,10 +1382,9 @@ public: groups.push_back(group_data{ { sizeof...(Owned), sizeof...(Get), sizeof...(Exclude) }, decltype(group_data::group){new handler_type{}, [](void *gptr) { delete static_cast(gptr); }}, - [](const component *other) ENTT_NOEXCEPT { - const component ctypes[] = { type()..., type()..., type()... }; - return std::equal(std::begin(ctypes), std::end(ctypes), other); - } + [](const component ctype) ENTT_NOEXCEPT { return ((ctype == type()) || ...); }, + [](const component ctype) ENTT_NOEXCEPT { return ((ctype == type()) || ...); }, + [](const component ctype) ENTT_NOEXCEPT { return ((ctype == type()) || ...); } }); curr = static_cast(groups.back().group.get());