The capture-list is what you put inbetween the square brackets. Look at this example:
void foo()
{
int i = 0;
[]()
{
i += 2;
}
}
Here the lambda does not capture anything, thus it will not have access to the enclosing scope, and will not know what i is. Now, let’s capture everything by reference:
void foo()
{
int i = 0;
[&]()//note the &. It means we are capturing all of the enclosing variables by reference
{
i += 2;
}
cout << 2;
}
In this example, the i inside the lambda is a reference to the i in the enclosing scope.
In your example, you have a lambda inside a member-function of an object. You are trying to call the object’s function: setValues(v), but your capture list is empty, so your lambda does not know what setValues is. Now, if you capture this in the lambda, the lambda will have access to all of the object’s methods, because setValues(v) is the same as this->setValues(v) in your case, and the error will be gone.