1
0
Эх сурвалжийг харах

sigh: flip the last commit on its head and drop redundant functions rather than merging them

Michele Caini 3 жил өмнө
parent
commit
31808bd9a2

+ 10 - 10
src/entt/entity/observer.hpp

@@ -195,10 +195,10 @@ class basic_observer: private basic_storage<Mask, typename Registry::entity_type
         }
         }
 
 
         static void disconnect(basic_observer &obs, Registry &reg) {
         static void disconnect(basic_observer &obs, Registry &reg) {
-            (reg.template on_destroy<Require>().disconnect(obs), ...);
-            (reg.template on_construct<Reject>().disconnect(obs), ...);
-            reg.template on_update<AnyOf>().disconnect(obs);
-            reg.template on_destroy<AnyOf>().disconnect(obs);
+            (reg.template on_destroy<Require>().disconnect(&obs), ...);
+            (reg.template on_construct<Reject>().disconnect(&obs), ...);
+            reg.template on_update<AnyOf>().disconnect(&obs);
+            reg.template on_destroy<AnyOf>().disconnect(&obs);
         }
         }
     };
     };
 
 
@@ -241,12 +241,12 @@ class basic_observer: private basic_storage<Mask, typename Registry::entity_type
         }
         }
 
 
         static void disconnect(basic_observer &obs, Registry &reg) {
         static void disconnect(basic_observer &obs, Registry &reg) {
-            (reg.template on_destroy<Require>().disconnect(obs), ...);
-            (reg.template on_construct<Reject>().disconnect(obs), ...);
-            (reg.template on_construct<AllOf>().disconnect(obs), ...);
-            (reg.template on_destroy<NoneOf>().disconnect(obs), ...);
-            (reg.template on_destroy<AllOf>().disconnect(obs), ...);
-            (reg.template on_construct<NoneOf>().disconnect(obs), ...);
+            (reg.template on_destroy<Require>().disconnect(&obs), ...);
+            (reg.template on_construct<Reject>().disconnect(&obs), ...);
+            (reg.template on_construct<AllOf>().disconnect(&obs), ...);
+            (reg.template on_destroy<NoneOf>().disconnect(&obs), ...);
+            (reg.template on_destroy<AllOf>().disconnect(&obs), ...);
+            (reg.template on_construct<NoneOf>().disconnect(&obs), ...);
         }
         }
     };
     };
 
 

+ 5 - 11
src/entt/signal/sigh.hpp

@@ -508,19 +508,13 @@ public:
     /**
     /**
      * @brief Disconnects free functions with payload or bound members from a
      * @brief Disconnects free functions with payload or bound members from a
      * signal.
      * signal.
-     * @tparam Type Type of class or type of payload.
      * @param value_or_instance A valid object that fits the purpose.
      * @param value_or_instance A valid object that fits the purpose.
      */
      */
-    template<typename Type>
-    void disconnect(Type &&value_or_instance) {
-        if constexpr(std::is_pointer_v<std::remove_reference_t<Type>>) {
-            if(value_or_instance) {
-                auto &calls = signal->calls;
-                auto predicate = [value_or_instance](const auto &delegate) { return delegate.data() == value_or_instance; };
-                calls.erase(std::remove_if(calls.begin(), calls.end(), std::move(predicate)), calls.end());
-            }
-        } else {
-            disconnect(&value_or_instance);
+    void disconnect(const void *value_or_instance) {
+        if(value_or_instance) {
+            auto &calls = signal->calls;
+            auto predicate = [value_or_instance](const auto &delegate) { return delegate.data() == value_or_instance; };
+            calls.erase(std::remove_if(calls.begin(), calls.end(), std::move(predicate)), calls.end());
         }
         }
     }
     }
 
 

+ 2 - 2
test/entt/signal/sigh.cpp

@@ -171,7 +171,7 @@ TEST_F(SigH, FunctionsWithPayload) {
     ASSERT_EQ(v, 0);
     ASSERT_EQ(v, 0);
 
 
     sink.connect<&sigh_listener::f>(v);
     sink.connect<&sigh_listener::f>(v);
-    sink.disconnect(v);
+    sink.disconnect(&v);
     sigh.publish();
     sigh.publish();
 
 
     ASSERT_EQ(v, 0);
     ASSERT_EQ(v, 0);
@@ -542,7 +542,7 @@ TEST_F(SigH, CustomAllocator) {
     sink.template connect<&sigh_listener::g>(listener);
     sink.template connect<&sigh_listener::g>(listener);
 
 
     decltype(sigh) copy{sigh, allocator};
     decltype(sigh) copy{sigh, allocator};
-    sink.disconnect(listener);
+    sink.disconnect(&listener);
 
 
     ASSERT_TRUE(sigh.empty());
     ASSERT_TRUE(sigh.empty());
     ASSERT_FALSE(copy.empty());
     ASSERT_FALSE(copy.empty());