paizza paizza - 1 year ago 76
C++ Question

How to pass only second argument of a bind function?

I'm using a generic EventEmitter instance:

EventEmitter mEventHandler;

So I've defined this bind:

function<void(int, double)> onSetMin = bind(&ILFO::SetMin, this, placeholders::_2);
mEventHandler.on(kParamID, onSetMin);

and the
such as:

mEventHandler.emit(paramID, someInt, someDouble);

which is "generic" as said, and set 2 params. But my specific function
need just one param (which would be
in this case):

void ILFO::SetMin(double min);

How would you just pass second paramter from bind?

Answer Source

Easier to use a lambda for your problem I think:

function<void(int, double)> onSetMin = [this](int dummy, double d) { SetMin(d); };
mEventHandler.on(kParamID, onSetMin);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download