I want to be able to obtain a function pointer to a lambda in C++.
I can do:
int (*c)(int) = [](int i) { return i; };
And, of cours
This fails:
auto *b = [](int i) { return i; };
because the lambda is not a pointer. auto does not allow for conversions. Even though the lambda is convertible to something that is a pointer, that's not going to be done for you - you have to do it yourself. Whether with a cast:
auto *c = static_cast([](int i){return i;});
Or with some sorcery:
auto *d = +[](int i) { return i; };