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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.