boost bind callback function pointer as a parameter
- by Takashi-kun
I am trying to pass a function pointer using boost::bind.
void
Class::ThreadFunction(Type(*callbackFunc)(message_type::ptr&))
{
}
boost::shared_ptr<boost::thread>
Class::Init(Type(*callbackFunc)(message_type::ptr&))
{
return boost::shared_ptr<boost::thread> (
new boost::thread(boost::bind(&Class::ThreadFunction, callbackFunc))
);
}
I get the following errors:
1>C:\dev\sapphire\boost_1_46_1\boost/bind/mem_fn.hpp(362) : warning C4180: qualifier applied to function type has no meaning; ignored
1>C:\dev\sapphire\boost_1_46_1\boost/bind/mem_fn.hpp(333) : error C2296: '->*' : illegal, left operand has type 'Type (__cdecl **)(message_type::ptr &)'
However, I was able to change to the following, it works fine:
void
ThreadFunction(Type(*callbackFunc)(message_type::ptr&))
{
}
boost::shared_ptr<boost::thread>
Class::Init(Type(*callbackFunc)(message_type::ptr&))
{
return boost::shared_ptr<boost::thread> (
new boost::thread(boost::bind(&ThreadFunction, callbackFunc))
);
}
Why do I get those errors if I declare the method in the Class class?