Capturing [*this] in Lambda Expressions
Let's look at how to capture [*this] in Lambda Expressions.
We'll cover the following...
We'll cover the following...
When you write a lambda inside a class method, you can reference a member variable by capturing this. For example:
In the line with auto addWordLambda = [this]() {... } we capture this pointer and later we can access m_str.
Please notice that we captured this by value… to a pointer. You have access to the member variable, not its copy. The same effect happens when you capture by [=] or [&]. That’s why ...