sigh: flip the last commit on its head and drop redundant functions rather than merging them
This commit is contained in:
@@ -195,10 +195,10 @@ class basic_observer: private basic_storage<Mask, typename Registry::entity_type
|
||||
}
|
||||
|
||||
static void disconnect(basic_observer &obs, Registry ®) {
|
||||
(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.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), ...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -508,19 +508,13 @@ public:
|
||||
/**
|
||||
* @brief Disconnects free functions with payload or bound members from a
|
||||
* signal.
|
||||
* @tparam Type Type of class or type of payload.
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ TEST_F(SigH, FunctionsWithPayload) {
|
||||
ASSERT_EQ(v, 0);
|
||||
|
||||
sink.connect<&sigh_listener::f>(v);
|
||||
sink.disconnect(v);
|
||||
sink.disconnect(&v);
|
||||
sigh.publish();
|
||||
|
||||
ASSERT_EQ(v, 0);
|
||||
@@ -542,7 +542,7 @@ TEST_F(SigH, CustomAllocator) {
|
||||
sink.template connect<&sigh_listener::g>(listener);
|
||||
|
||||
decltype(sigh) copy{sigh, allocator};
|
||||
sink.disconnect(listener);
|
||||
sink.disconnect(&listener);
|
||||
|
||||
ASSERT_TRUE(sigh.empty());
|
||||
ASSERT_FALSE(copy.empty());
|
||||
|
||||
Reference in New Issue
Block a user