Here in C++, i want to use a variable invalidNumber which is already available in a function scope inside the lambda. There was a compiler error when i tried the below code. How to make Lambda function to use it's surrounding variables in the scope where it's been defined.
void func()
{
set<int> intSet{10,20,30,40};
int invalidNumber = 100;
intSet.erase(std::remove_if(intSet, [](int comp) { return comp == 0 || comp == invalidNumber; }), intSet.end());
}