OS : win7 64bits
compiler : visual C++ 2005
boost version : boost_1_44_0
#include <gtest/gtest.h>
#include <tchar.h>
#include <boost/signal.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/mem_fn.hpp>
class Slot : public boost::signals::trackable
{
public:
void Update(int)
{
::printf("Signaled!!\n");
}
};
int _tmain(int argc, _TCHAR* argv[])
{
boost::signal<void (int)> s;
Slot *slot = new Slot();
boost::function<void (int)> f = boost::bind(&Slot::Update, slot, _1);
/**
* If signal is connected using this way, Update is called only once.
*/
//s.connect(boost::bind(boost::mem_fn(&Slot::Update), slot, _1));
/**
* If signal is connected using this way, Update is called twice.
* trackable is useless in this case!!!
*/
s.connect(f);
s(1);
delete slot;
s(2);
return 0;
}
A problem of my colleague, I don't know what is boost::signal doing.
Thanks a lot
Sorry, we found the problem, boost::signal do not support boost::function or
boost::lambda expression