I've searched SO and Google but unfortunately couldn't find an answer. I'm looking for the correct syntax to prototype a lambda. I've tried:
int g = [] () -> int;
But I get errors. Is there a way to prototype a lambda? If so, how?
You can't prototype a lambda. You can create a function object holding the lambda expression, but that wouldn't be prototyping but rather definition. E.g.: auto f = [] (int x, int y) { return x + y; };
You can also declare a standard function pointer with a type corresponding to your desired lambda signature.
typedef bool (*TheFunctionSig) (int)and useTheFunctionSigas the parameter type of my function. What's the analog with accepting lambdas? I want to be able to capture values, so I can't use a classic function ptr.