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
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.