Both ArduinoSTL and StandardCplusplus don't support them. They implement the version that is compatible with c++03 (not c++11).
This functionality is handy when you design libraries that work with callbacks. And you do need them, if your Arduino does more than one thing simultaneously.
I tried also several other options, but none was enough. Most complete thing I found, Passing capturing lambda as function pointer, does not support plain function pointers and does not allow me to hold the function
object as a member of the structure, because the type of the object depends on the lambda (not only its signature, like in std::function
).
In particular, I need a functor that
- can store both capturing lambdas and plain function wrappers
- has a type that depends only on the signature of the function, so I can store it as a class member.
std::function
seems very intimidating to me. Do you know something that is already written, that I can use to store both capturing lambdas and function pointers?std::function
is. You will have to implement some version ofstd::function
. You can make a simplified implementation, but there's no way around it. Although it is not clear why you claim that you need callbacks to do "more than one thing simultaneously".