Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我搜索了 SO 和 Google,但不幸的是找不到答案。我正在寻找正确的语法来原型化 lambda。我试过了:
int g = [] () -> int;
但我得到错误。有没有办法制作 lambda 原型?如果是这样,怎么做?
您不能对 lambda 进行原型设计。您可以创建一个包含 lambda 表达式的函数对象,但这不是原型设计,而是定义。例如:auto f = [] (int x, int y) { return x + y; }; 您还可以声明一个标准函数指针,其类型对应于您所需的 lambda 签名。
auto f = [] (int x, int y) { return x + y; };