jeudi 24 août 2017

How to translate ::* operator and member_fn in this given code?

To my best knowledge: void (A::*p)() = &A::test_func; means that p is a pointer to the member function void A::test_func(), and std::member_fn(...) can be used to wrap a pointer to a member function.

But in the following code snippet I couldn't translate what void (Handler::*)() and Handler::*member_fn mean.

class Handler;

std::pair<boost::shared_ptr<Handler>, void (Handler::*)()> cb = env->job_queue.sync_pop();

if (cb.first==0 or cb.second==0) {
    enswer::acr::sleep(10);
    continue;
}

void (Handler::*member_fn)() = cb.second;
(cb.first.get()->*member_fn)();

Aucun commentaire:

Enregistrer un commentaire