Reputation: 1
class EmulNet
{
public:
int ENrecv(Address *myaddr, std::function<int (void*,char*,int)> fn, struct timeval *t, int
times, void *queue);
};
class MP1Node{
public:
int recvLoop();
int enqueueWrapper(void *env, char *buff, int size);
};
int MP1Node::recvLoop() {
return emulNet->ENrecv(&(memberNode->addr), std::bind(&MP1Node::enqueueWrapper,this), NULL, 1, &(memberNode->mp1q));
}
Note - emulNet is an object of class EmulNet
Above code doesn't work.
No viable conversion from '__bind<int (MP1Node::*)(void *, char *, int), MP1Node *>' to 'std::function<int (void *, char *, int)>'
Upvotes: 0
Views: 61
Reputation: 52611
If you insist on using std::bind
, make it
std::bind(&MP1Node::enqueueWrapper,this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
Alternatively, use a lambda:
[this](void *env, char *buff, int size) { return enqueueWrapper(env, buff, size); }
(replace your bind
call with the above).
Upvotes: 1