c++ - C++/CX 中的 [this] 是什么? (Windows 8)

标签 c++ c++11 windows-8 c++-cx

我正在关注 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/

相关文章:

c++ - union 正确用法

c++ - 如何将我的类转换为命名空间

c++ - std::get 与 std::tuple 的效率

windows - 应该将 npm 全局安装在 AppData\Roaming 中吗?

javascript - Metro 应用程序可以切换到上次运行的应用程序吗?

c++ - TEST() 名称中的无下划线规则有多严格?

c++ - Microsoft 如何处理 UTF-16 在其 C++ 标准库实现中是可变长度编码这一事实

c++ - 如何使 is_pod<T> 测试在编译期间而不是执行期间执行?

C++11 - move 包含文件流的对象

java - JVM 在退出时挂起