在C++ 0x中,我想知道lambda函数的类型是什么.特别:
#include<iostream>
type1 foo(int x){
return [x](int y)->int{return x * y;};
}
int main(){
std::cout<<foo(3)(4);//would output 12
type2 bar = foo(5);
std::cout<<bar(6);//would output 30
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我需要更换type1/type2才能使上述功能正常工作?希望你能看到我想要完成的事情,所以即使直接替换type1和type2是不可能的,也许你可以引导我朝着正确的方向前进.
换一种说法:
谢谢!
编辑:我正在使用visual studio 2010进行编译