Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does [&] mean in C++ [duplicate]

Tags:

c++

visual-c++

I saw a piece of code like this:

Foo(
  [&](int a){
    ...
  }
);

Seems like an inner function, but why there is a [&]?

like image 547
Allan Jiang Avatar asked Feb 21 '14 19:02

Allan Jiang


1 Answers

This is a lambda, the [&] means that:

captures all automatic variables mentioned in the body of the lambda by reference

like image 82
Shafik Yaghmour Avatar answered Oct 14 '22 04:10

Shafik Yaghmour