1

I have a basic syntax question. I am trying to understand the meaning of an operator within square brackets when used in an assignment. E.g.

a = [&] (const std::string&) { ... };

a = [=] (const std::string& b) { ... };

Thanks,

Jason
  • 36,170
  • 5
  • 26
  • 60
user3622140
  • 65
  • 1
  • 7
  • Does this answer your question? [How does generic lambda work in C++14?](https://stackoverflow.com/questions/17233547/how-does-generic-lambda-work-in-c14) – Jason Jul 30 '22 at 07:23

1 Answers1

5

They distinguish between capturing variables by reference ([&]) or by value ([=]) in closures. See http://en.cppreference.com/w/cpp/language/lambda for details.

thus spake a.k.
  • 1,607
  • 12
  • 12