I am trying to store a member function from an object to call it when an appropriate event happens. Unfortunately this code gives a lot of error messages. Can anybody help me?
class MainPage
{
public:
MainPage::MainPage(void)
{
image1 = new STImagePanel("Untitled.png");
image1->OnPointerPressedHandler->add(&MainPage::imageMousePressed,this);
}
void MainPage::imageMousePressed(STObject* sender, STPointerEventArg * args)
{
MainPage * dsda = (MainPage*)this;
pres = true;
}
};
template<class SENDERTYPE, class ARG>
struct callbackInfo
{
boost::function<void(SENDERTYPE, ARG)> func;
};
template<class SENDERTYPE, class ARG>
class STEventHandler
{
public:
template<class T, class P>
void add(T x, P that)
{
//The following line gives the error
callbackInfo<SENDERTYPE,ARG> tmp { boost::bind(x,that,_2)};
functions->addLast(tmp);
}
private:
STLinkedList<callbackInfo<SENDERTYPE,ARG>>* functions;
}
This gives the following errors:
http://pastie.org/8014181
Update:
with the following correction it works fine:
template<class T, class P>
void add(T x, P that)
{
boost::function<void(SENDERTYPE,ARG)> func(boost::bind(x,that,_1,_2));
callbackInfo<SENDERTYPE,ARG> tmp;
tmp.func = func;
}