I'm not sure, but maybe you can help me.
How can I access to a variable inside a lambda? Example:
float lim;
int main()
{
std::cin >> lim;
std::vector<float> v = {1.0f,4.5f,3.9f,0.2f,8.4f};
v.erase(std::remove_if(v.begin(),v.end(),[](float f){return f > lim}),v.end());
for (auto i : v) std::cout << i;
return 0;
}
So this example works, I can specify a value 'lim' and all values in the vector bigger than lim will remove inside the vector. But how can I do this avoiding a global variable lim to hold the value?
Thanks.