#include <iostream>
using namespace std;
int main ()
{
int x=0;
// auto lambda=[x](){
// x++;//we cannot increment x as it is const
// cout<<x<<endl;
// };
auto lambda=[x]() mutable{
x++;
cout<<x<<endl;
};
lambda();
return 0;
}
Here whats the benifit by making const to capture by value.It make sense for capture by reference as the caller can be sure the passed argument will not change.