@esoterik said:also
auto foo = [](type1 var1, type2 var2) -> int {...};
instead of
std::function<int (type1 var1, type2 var2)> foo = [](type1 var1, type2 var2) -> int {...};
n.b. i think i got that std::function syntax right
You've got the std::function syntax right, but not the equivalence. The statements are very different. The first keeps the function pointer encoded in the type, so the resulting call will be to direct operand and the compiler can possibly even inline the closure. The later will wrap the closure in an object with virtual method to dispatch to the function in a totally unoptimizable way.
No, there is no equivalent for the former without using auto (unless you are getting the closure as argument, in which case you can have compiler infer template parameter from argument and use that).