我正在使用将函数指针传递给方法调用的第 3 方库。
class RTSPClient{
public:
...
typedef void (responseHandler)(RTSPClient* rtspClient,
int resultCode, char* resultString);
...
unsigned sendOptionsCommand(responseHandler* responseHandler,
Authenticator* authenticator = NULL);
};
正常用法如下:
void continueAfterOPTIONS(RTSPClient* client,
int resultCode, char* resultString);
....
RTSPClient* pClient;
....
pClient->sendOptionsCommand(continueAfterOPTIONS, NULL);
现在我想让 continueAfterOPTIONS 方法成为一个类的成员函数。通常我使用 boost::bind 来做到这一点:
pRtspClient>sendOptionsCommand(boost::bind(&RtspClientSessionManager::continueAfterOPTIONS, this), NULL);
导致
error C2664: 'RTSPClient::sendOptionsCommand' : cannot convert parameter 1 from 'boost::_bi::bind_t<R,F,L>' to 'RTSPClient::responseHandler (__cdecl *)'
我尝试为函数的参数添加占位符,但这没有任何区别。我正在尝试做的事情可能吗?有没有办法投射绑定结果?
谢谢!