typedef boost::signals2::signal<void ()> signal_t;
class AAA {
public:
void Connect(const signal_t::slot_type& subscriber)
{
return m_sig.connect(subscriber);
}
void FireSignal()
{
m_sig();
}
private:
signal_t sig;
};
// Global
AAA a;
BBB b;
// Some scope
{
...
a.Connect(boost::bind(&BBB:foo, &b));
...
}
Now the temporary object returned by previous boost::bind goes out of scope and gets destroyed However the temporary object is passed to AAA::Connect by reference. Now lets say at some point, object a.FireSignal() is called, does the signal calls a function object that's already destroyed??? How does it work otherwise???