I'm abstracting the interrupt handling on multiple microcontrollers.
The ARM Cortex M-3/4 ones do greatly support the STL, but the
ATMega328p (which are greatly used) do not support the C++ STL.
I'd like to still offer the possibility to register callbacks for specific interrupts utilizing the std::function
additionally to the basic C-style function pointer.
I haven't tested it yet, but was told that the C++ lambdas can do a lot of stuff compared to the simple function pointers, especially when it comes to capturing variables and references.
I'd like to change the defining header class(if necessary) and the implementing classes(if necessary, might not be necessary, because the implementation will simply be missing) in order to remove the member function definition at compile time depending on whether the controller supports or doesn't support the STL. I was wondering if C++ offers such a test or if it's somehow possible to do this by including an STL header and somehow test, whether the include failed or not?
...
#include <functional>
class InterruptVectorTable
{
bool setCallback(ValueType InterruptNumber, void (*Callback)(void));
bool setCallback(ValueType InterruptNumber, std::functional<void(void)> Callback);
}
If both definitions are not allowed at the same time, then I'd like to preferably use the std::function
.