Difference between const auto and auto for lambda

Is there any (useful?) Difference between:

auto test = [..](..){..}; 

and

 const auto test = [..](..){..}; 

?

+6
source share
1 answer

Yes, if the lambda is declared mutable, then you cannot invoke it in the second case.

 int x = 0; const auto test = [x]() mutable { ++x; }; test(); // error 
+4
source

All Articles