File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -594,5 +594,8 @@ namespace autowiring {
594
594
// template format of the earlier function call overload, overload resolution will never
595
595
// select this variant.
596
596
// void operator()(Args... args) const;
597
+
598
+ bool has_listeners (void ) const { return m_pFirstListener != nullptr ; }
599
+ operator bool () const { return has_listeners (); }
597
600
};
598
601
}
Original file line number Diff line number Diff line change @@ -819,3 +819,12 @@ TEST_F(AutoSignalTest, MoveInInvoke) {
819
819
ASSERT_NE (nullptr , vRecovered);
820
820
ASSERT_EQ (404 , *vRecovered) << " Recovered unique pointer was not the expected value" ;
821
821
}
822
+
823
+ TEST_F (AutoSignalTest, ListenerCheck) {
824
+ autowiring::signal <void ()> s;
825
+ ASSERT_FALSE (s) << " Signal did not correctly report it had no listeners" ;
826
+ registration_t reg = s += [] {};
827
+ ASSERT_TRUE (s) << " Signal stated that it had no listeners when it should have had at least one" ;
828
+ s -= reg;
829
+ ASSERT_FALSE (s) << " Signal believed it still had listeners even after they were all unregistered" ;
830
+ }
You can’t perform that action at this time.
0 commit comments