C/C++
未读创建一个匿名函数并执行。Objective-C采用的是上尖号^,而C++ 11采用的是配对的方括号[]。实例如下:
12345678#include <iostream>using namespace std;int main(){ []{ cout << "Hello,Worldn"; }();}
我们也可以方便的将这个创建的匿名函数赋值出来调用:
12345678910#include <iostream>using namespace std;int main(){ int i = 1024; auto func = [](int i) { // (int i) 是指传入改匿名函数的参数 cout << i; }; func(i);}
捕获选项
[] Capture nothing (or, a scorched earth strategy?)
[&] Ca ...