How can I describe a map of lambda? I want to have a map of lambda which will be called on event (just as a simple callback). The lambda type is constant.
Use the <functional>
header and the std::function
template class. This allows you to specify function objects with a fixed method signature.
std::map< unsigned int, std::function<int(int,int)> > callbackMap;
Assuming that you index the callbacks using an unsigned int
, the above map stores functions that take in two int
and return an int
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With