muwerk ustd Library
A low-resource, minimal implementation of Arrays, Maps and Queues for low-resource avrs.
functional.h File Reference

Go to the source code of this file.

Detailed Description

std::function<> equivalent for low-resource AVRs

functional.h is a minimal, no-dependency implementation of functionals for AVRs, taken from project: functional-avr by winterscar.

Make sure to provide the required platform define before including ustd headers.

Note: if you are only interested in using functionals, it might be better to directly use project functional-avr by winterscar.

An example:

#define __UNO__ 1 // Appropriate platform define required
// Note: only __ARDUINO__ is supported.
// __ATTINY__ is no longer supported.
// All other platforms should use std::function<>
// from standard library.
#include <functional.h>
#if defined (__ARDUINO__)
typedef ustd::function<void()> T_TASK;
#else // use standard library instead:
typedef std::function<void()> T_TASK;
#endif
void task(T_TASK *tsk) {
tsk();
}
class Something {
Something() {
auto ft = [=]() { this->callback(); };
task(ft);
}
void callback() {
// do something
}
}