I am still new to C++ lambdas, but this is a valid piece of code that I have worked out, while reading up on them:
std::vector<std::string> vecFileNames;
// using Lambda function to set the function called as the "for_each" iterates across
// the vector. "currentFileName" is parameter, and it is only in scope inside
// the curly brackets defining the Lambda function body
std::for_each(vecFileNames.begin(), vecFileNames.end(), [&](const std::string ¤tFileName)
{
if (currentFileName.length() > 0)
{
// got a file name we can do something with here
}
});
the "[&]" means that variables defined outside of the lambda function are available inside the lambda function, but the parameter to the function, "currentFileName" in this example, does not exist outside of the function, and is created at this point. So we are creating new variable names here, so anything VA suggests is likely to be incorrect, since we have no reason to assume you are about to type a known symbol.