I’m using a 3rd party library that passes function pointers to a method call.
class RTSPClient{
public:
...
typedef void (responseHandler)(RTSPClient* rtspClient,
int resultCode, char* resultString);
...
unsigned sendOptionsCommand(responseHandler* responseHandler,
Authenticator* authenticator = NULL);
};
Normal usage looks as follows:
void continueAfterOPTIONS(RTSPClient* client,
int resultCode, char* resultString);
....
RTSPClient* pClient;
....
pClient->sendOptionsCommand(continueAfterOPTIONS, NULL);
Now I would like to make the continueAfterOPTIONS method a member function of a class.
Usually I use boost::bind to do this:
pRtspClient>sendOptionsCommand(boost::bind(&RtspClientSessionManager::continueAfterOPTIONS, this), NULL);
resulting in
error C2664: 'RTSPClient::sendOptionsCommand' : cannot convert parameter 1 from 'boost::_bi::bind_t<R,F,L>' to 'RTSPClient::responseHandler (__cdecl *)'
I tried adding in place holders for the arguments of the function and that made no difference. Is what I’m trying to do possible? Is there perhaps a way to cast the bind result?
Thanks!
Not out of the box. However, let me sketch how you could do it.
It’s of course easier if you can derive your
RtspClientSessionManagerfromRtspClient