paizza paizza - 5 months ago 16
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?


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);