3 ms·
I've also written my own "version" of function but intentionally lightweight, for an embedded project: https://github.com/ambrop72/aprinter/blob/master/aprinter
by ambrop7 10y ago
I've also written my own "version" of function but intentionally lightweight, for an embedded project: https://github.com/ambrop72/aprinter/blob/master/aprinter/base/Callback.h https://github.com/ambrop72/aprinter/blob/master/aprinter/ba...
Callback<void(int, int)> f = APRINTER_CB_OBJFUNC(&ThisClass::function, this);
One magic thing is that the macro is just a value, it figures out the type itself.
There's zero memory allocation. The Callback class just contains a function pointer and a void pointer. So you can't bind argument values other than the object pointer, but I have no need for that.