您好,我是一名学生,正在开发一个使用成员函数回调的程序。我遇到了 bind 的使用,这正是我所需要的。我只是很难让它工作。
下面是相关代码和编译错误
// this is the API function to register callback
void register_callback_datapoint(void(*)(datapoint_t *datapoint) cb_datapoint )
// this function is my callback
void datapoint_update(datapoint_t* datapoint);
// this code is called in the aggregateThread class
boost::function<void(datapoint_t*)> f;
f = bind(&aggregateThread::datapoint_update, this, std::tr1::placeholders::_1);
register_callback_datapoint(f);
// here is the compile error
cannot convert ‘boost::function<void(datapoint_opaque_t*)>’ to ‘void (*)(datapoint_t*)
{aka void (*)(datapoint_opaque_t*)}’ for argument ‘1’ to ‘void
register_callback_datapoint(void (*)(datapoint_t*))’
有人可以帮我吗?谢谢