As @timemage explains in a comment, you cannot pass a capturing lambda
to a function that expects a plain pointer to function. There is,
however, a way out of this: the Ticker class provides an overload of
the attach() method that allows you to provide a parameter of any type
to tour callback:
template<typename TArg>
void attach(float seconds, void (*callback)(TArg), TArg arg)
You can use this version of attach() and provide it both
- a non-capturing lambda that getgets a reference (or pointer) to
-
systemManagerthat reference or - that pointer as a third argument.
Edit: I did a few tests, and it seems my compiler cannot properly perform template argument deduction in this case, but the approach works if you explicitly specialize the template. Namely:
tickerSystemManager.attach<typeof systemManager>(
1000,
[](typeof systemManager p){ p->sync(); },
systemManager);