There are other solutions on StackOverflow like this which suggest same way of converting boost::function into function pointer. But the same code generates error for me. Do I need to introduce reinterpret_cast
or there is a cleaner why of doing this?
Below is the sample code which generates error:
void
Do ( int (*callback) (MYType1 const*, MYType2* ) )
{
MYType2 tmp;
boost:: function <int(MYType1 const*)> fun = boost::bind( callback, _1, &tmp );
// My intention is to create c style function pointer out of `fun`
// but below line is generating error:
// error: cannot convert 'boost::function < int () (const MYType1*), std::allocator<void> >' to 'int (*)(const MYType1*)' in initialization
int (*c)(MYType1 const*) = &fun;
}