我正在关注 this指南,我正在点击包含术语 [this]
的这些代码部分(只需按 Ctrl-F 即可;您会明白我的意思)。
我不确定这是 C++ 还是 C++/CX,但不管怎样,我都不知道它是什么。
这是什么?
最佳答案
它被称为“Lambda 闭包”,表示当前实例 (this
) 将被传递到 lambda 主体中(使您能够使用它的变量,并调用它的方法)。
此页面很好地总结了 Lambda 闭包:
http://www.cprogramming.com/c++11/c++11-lambda-closures.html
[] Capture nothing (or, a scorched earth strategy?)
[&] Capture any referenced variable by reference
[=] Capture any referenced variable by making a copy
[=, &foo] Capture any referenced variable by making a copy, but capture variable foo by reference
[bar] Capture bar by making a copy; don't copy anything else
[this] Capture the this pointer of the enclosing class
关于c++ - C++/CX 中的 [this] 是什么? (Windows 8),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13472280/