PaulStoffregen
Well-known member
I'm considering changing all or most of Teensy callback APIs (IntervalTimer, attachInterrupt, usbMIDI, more to be added) to properly support C++ functions. But not std::function which allocates memory on the heap. Something "lightweight". Maybe one of these?
https://github.com/rosbacke/delegate
https://github.com/rosbacke/MCU-tools/tree/master/src/callback
https://github.com/Naios/function2
https://gist.github.com/twoscomplement/030818a6c38c5a983482dc3a385a3ab8
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0792r3.html
https://github.com/vittorioromeo/Experiments/blob/master/function_ref.cpp
The hard requirements are avoiding heap allocation, ability to call C functions, static C++ functions, class member functions, and MIT-like permissive license. Avoiding C++ template syntax in Arduino sketch code is highly desirable (but template syntax is ok inside libraries and their headers, and maybe we can adopt a practice of typedefs or #defines for the function def). Support for lambda functions would be nice, maybe even mutable lambda functions.
@luni - any thoughts on this?
https://github.com/rosbacke/delegate
https://github.com/rosbacke/MCU-tools/tree/master/src/callback
https://github.com/Naios/function2
https://gist.github.com/twoscomplement/030818a6c38c5a983482dc3a385a3ab8
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0792r3.html
https://github.com/vittorioromeo/Experiments/blob/master/function_ref.cpp
The hard requirements are avoiding heap allocation, ability to call C functions, static C++ functions, class member functions, and MIT-like permissive license. Avoiding C++ template syntax in Arduino sketch code is highly desirable (but template syntax is ok inside libraries and their headers, and maybe we can adopt a practice of typedefs or #defines for the function def). Support for lambda functions would be nice, maybe even mutable lambda functions.
@luni - any thoughts on this?