What does [&] mean before function? [duplicate]

It means that the lambda function will capture all variables in the scope by reference.

To use other variables other than what was passed to lambda within it, we can use capture-clause [].
You can capture by both reference and value, which you can specify using & and = respectively:

  • [=] capture all variables within scope by value
  • [&] capture all variables within scope by reference
  • [&var] capture var by reference
  • [&, var] specify that the default
    way of capturing is by reference and we want to capture var
  • [=, &var] capture the variables in scope by value by default, but capture var using reference
    instead

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)