Browse Source

group: make types explicit for the next/prev functions

Michele Caini 3 years ago
parent
commit
1646217f09
2 changed files with 13 additions and 12 deletions
  1. 6 10
      src/entt/entity/group.hpp
  2. 7 2
      src/entt/entity/registry.hpp

+ 6 - 10
src/entt/entity/group.hpp

@@ -154,18 +154,14 @@ public:
         }
     }
 
-    void previous(const void *elem) {
-        if(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);
-        }
+    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);
     }
 
-    void next(const void *elem) {
-        if(elem) {
-            std::apply([this, elem](auto *...cpool) { ((cpool->on_construct().disconnect(this), cpool->on_construct().before(elem).template connect<&group_handler::push_on_construct>(*this)), ...); }, pools);
-            std::apply([this, elem](auto *...cpool) { ((cpool->on_destroy().disconnect(this), cpool->on_destroy().before(elem).template connect<&group_handler::push_on_destroy>(*this)), ...); }, filter);
-        }
+    void next(const owning_group_descriptor &elem) {
+        std::apply([this, &elem](auto *...cpool) { ((cpool->on_construct().disconnect(this), cpool->on_construct().before(&elem).template connect<&group_handler::push_on_construct>(*this)), ...); }, pools);
+        std::apply([this, &elem](auto *...cpool) { ((cpool->on_destroy().disconnect(this), cpool->on_destroy().before(&elem).template connect<&group_handler::push_on_destroy>(*this)), ...); }, filter);
     }
 
     [[nodiscard]] std::size_t length() const noexcept {

+ 7 - 2
src/entt/entity/registry.hpp

@@ -1247,8 +1247,13 @@ public:
                 }
             }
 
-            handler->previous(prev);
-            handler->next(next);
+            if(prev) {
+                handler->previous(*prev);
+            }
+
+            if(next) {
+                handler->next(*next);
+            }
 
             return {*handler};
         }