How do I turn below function into a typedef?
auto fn = [&] (int x) { doSomething(x, 3); }
You can use decltype
to get the exact type:
auto fn = [&] (int x) { doSomething(x, 3); };
using lambda_type = decltype(fn);
But if you merely want to know a compatible, more general type, say for passing the lambda as argument to another function, you can use std::function<void(int)>
(as Joachim mentions).
How about
using my_function_type = std::function<void(int)>;