Question.2
A captureless lambda is passed to a C-style callback API:
void register_irq(void (*cb)(int)); // C API register_irq([](int code) { log_error(code); });
Why does this work even though the API expects a raw function pointer?
Select Answer
All lambdas are function pointers
A lambda with empty captures [] has no state -- the compiler can convert it to a plain function pointer; it is identical to a regular C function
The compiler wraps the lambda in std::function automatically
register_irq is overloaded for lambdas