boost bind callback function pointer as a parameter
Posted
by
Takashi-kun
on Stack Overflow
See other posts from Stack Overflow
or by Takashi-kun
Published on 2011-11-22T01:27:06Z
Indexed on
2011/11/22
1:50 UTC
Read the original article
Hit count: 559
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?
© Stack Overflow or respective owner