Obtaining function pointer to lambda?

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(*)(int)>([](int i){return i;});

Or with some sorcery:

auto *d = +[](int i) { return i; };

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)