1
    #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.

user1438832
  • 493
  • 3
  • 10
  • Make sure to read all the answers to that question, since each of them provides a different view on the situation. – SingerOfTheFall Nov 09 '16 at 11:33
  • x isn't a const in the code you posted, and the question whether lambda should actually change x or not (capture by reference or not) is up to you. So, what are you asking? – kabanus Nov 09 '16 at 11:41
  • x is const in the commented code.i want to know why the capture by value is by defult const why not non const. – user1438832 Nov 09 '16 at 12:19

0 Answers0