Browse Source

registry: prepare for a storage based group handler

Michele Caini 3 years ago
parent
commit
df6d926dec
1 changed files with 9 additions and 9 deletions
  1. 9 9
      src/entt/entity/registry.hpp

+ 9 - 9
src/entt/entity/registry.hpp

@@ -248,11 +248,11 @@ class basic_registry {
     template<typename Type>
     template<typename Type>
     using storage_for_type = typename storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<std::remove_const_t<Type>>>::type;
     using storage_for_type = typename storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<std::remove_const_t<Type>>>::type;
 
 
-    template<typename...>
+    template<typename, typename, typename>
     struct group_handler;
     struct group_handler;
 
 
-    template<typename... Exclude, typename... Get, typename Owned, typename... Other>
-    struct group_handler<exclude_t<Exclude...>, get_t<Get...>, Owned, Other...> {
+    template<typename Owned, typename... Other, typename... Get, typename... Exclude>
+    struct group_handler<owned_t<Owned, Other...>, get_t<Get...>, exclude_t<Exclude...>> {
         // nasty workaround for an issue with the toolset v141 that doesn't accept a fold expression here
         // nasty workaround for an issue with the toolset v141 that doesn't accept a fold expression here
         static_assert(!std::disjunction_v<std::bool_constant<storage_for_type<Owned>::traits_type::in_place_delete>, std::bool_constant<storage_for_type<Other>::traits_type::in_place_delete>...>, "Groups do not support in-place delete");
         static_assert(!std::disjunction_v<std::bool_constant<storage_for_type<Owned>::traits_type::in_place_delete>, std::bool_constant<storage_for_type<Other>::traits_type::in_place_delete>...>, "Groups do not support in-place delete");
         std::size_t current{};
         std::size_t current{};
@@ -280,8 +280,8 @@ class basic_registry {
         }
         }
     };
     };
 
 
-    template<typename... Exclude, typename Get, typename... Other>
-    struct group_handler<exclude_t<Exclude...>, get_t<Get, Other...>>: basic_common_type {
+    template<typename Get, typename... Other, typename... Exclude>
+    struct group_handler<owned_t<>, get_t<Get, Other...>, exclude_t<Exclude...>>: basic_common_type {
         using basic_common_type::basic_common_type;
         using basic_common_type::basic_common_type;
 
 
         template<typename Type>
         template<typename Type>
@@ -1259,7 +1259,7 @@ public:
     template<typename Owned, typename... Other, typename... Get, typename... Exclude>
     template<typename Owned, typename... Other, typename... Get, typename... Exclude>
     [[nodiscard]] basic_group<owned_t<storage_for_type<Owned>, storage_for_type<Other>...>, get_t<storage_for_type<Get>...>, exclude_t<storage_for_type<Exclude>...>>
     [[nodiscard]] basic_group<owned_t<storage_for_type<Owned>, storage_for_type<Other>...>, get_t<storage_for_type<Get>...>, exclude_t<storage_for_type<Exclude>...>>
     group(get_t<Get...> = {}, exclude_t<Exclude...> = {}) {
     group(get_t<Get...> = {}, exclude_t<Exclude...> = {}) {
-        using handler_type = group_handler<exclude_t<std::remove_const_t<Exclude>...>, get_t<std::remove_const_t<Get>...>, std::remove_const_t<Owned>, std::remove_const_t<Other>...>;
+        using handler_type = group_handler<owned_t<std::remove_const_t<Owned>, std::remove_const_t<Other>...>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>;
 
 
         const auto cpools = std::forward_as_tuple(assure<std::remove_const_t<Owned>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Get>>()...);
         const auto cpools = std::forward_as_tuple(assure<std::remove_const_t<Owned>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Get>>()...);
         constexpr auto size = 1u + sizeof...(Other) + sizeof...(Get) + sizeof...(Exclude);
         constexpr auto size = 1u + sizeof...(Other) + sizeof...(Get) + sizeof...(Exclude);
@@ -1342,7 +1342,7 @@ public:
     template<typename Get, typename... Other, typename... Exclude>
     template<typename Get, typename... Other, typename... Exclude>
     [[nodiscard]] basic_group<owned_t<>, get_t<storage_for_type<Get>, storage_for_type<Other>...>, exclude_t<storage_for_type<Exclude>...>>
     [[nodiscard]] basic_group<owned_t<>, get_t<storage_for_type<Get>, storage_for_type<Other>...>, exclude_t<storage_for_type<Exclude>...>>
     group(get_t<Get, Other...>, exclude_t<Exclude...> = {}) {
     group(get_t<Get, Other...>, exclude_t<Exclude...> = {}) {
-        using handler_type = group_handler<exclude_t<std::remove_const_t<Exclude>...>, get_t<std::remove_const_t<Get>, std::remove_const_t<Other>...>>;
+        using handler_type = group_handler<owned_t<>, get_t<std::remove_const_t<Get>, std::remove_const_t<Other>...>, exclude_t<std::remove_const_t<Exclude>...>>;
 
 
         const auto cpools = std::forward_as_tuple(assure<std::remove_const_t<Get>>(), assure<std::remove_const_t<Other>>()...);
         const auto cpools = std::forward_as_tuple(assure<std::remove_const_t<Get>>(), assure<std::remove_const_t<Other>>()...);
         constexpr auto size = 1u + sizeof...(Other) + sizeof...(Exclude);
         constexpr auto size = 1u + sizeof...(Other) + sizeof...(Exclude);
@@ -1403,9 +1403,9 @@ public:
         if(it == groups.cend()) {
         if(it == groups.cend()) {
             return {};
             return {};
         } else {
         } else {
-            using handler_type = group_handler<exclude_t<std::remove_const_t<Exclude>...>, get_t<std::remove_const_t<Get>...>, std::remove_const_t<Owned>...>;
+            using handler_type = group_handler<owned_t<std::remove_const_t<Owned>...>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>;
 
 
-            if constexpr (sizeof...(Owned) == 0u) {
+            if constexpr(sizeof...(Owned) == 0u) {
                 return {*static_cast<handler_type *>(it->handler.get()), assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()..., assure<std::remove_const_t<Exclude>>()...};
                 return {*static_cast<handler_type *>(it->handler.get()), assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()..., assure<std::remove_const_t<Exclude>>()...};
             } else {
             } else {
                 return {static_cast<handler_type *>(it->handler.get())->current, assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()..., assure<std::remove_const_t<Exclude>>()...};
                 return {static_cast<handler_type *>(it->handler.get())->current, assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()..., assure<std::remove_const_t<Exclude>>()...};