Wednesday, 28 August 2013

What is the purpose of specifying captured variable in lambda expression?

What is the purpose of specifying captured variable in lambda expression?

I have this code:
int i = 0;
[&i](){i++;}();
But I can omit i and just use:
[&](){i++;}();
What is the purpose of specifying &i? (and similarly =var and =). Is it
affecting compile time or runtime performance?

No comments:

Post a Comment