I'm following this guide, and I'm hitting these parts of the code that include the term [this]
(Just Ctrl-F it; you'll see what I mean).
I'm not sure if this is a C++ thing or a C++/CX thing, but, either way, I don't know what it is.
What is it?
It's called a "Lambda Closure" and it's saying that the current instance ( this
) is to be passed into the lambda body (enabling you to use it's variables, and call it's methods).
This page gives a good summary of Lambda Closures:
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
It is syntax for a lambda anonymous function that captures the members of the class where it is defined. It is C++11.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.