[capture] Capture List. ‘[]’ functions as an introduction to a lambda expression; Essentially, lambda expression in C++ is functor, but it’s simpler and can be defined anywhere; The compiler judges if the following code is lambda function accoarding to the ‘[]’ introducer; The Capture List can capture the varibles in the context for lambda function to use;
(parameters)Parameter List. Shares the similar rule with the ordinary function. Can be omitted if no parameter pass is required;
mutablemutable identifier. Lambda functions will not change its parameters’ value, mutable can remove its constness; With the identifier, lambda functions parameter list cannot be omitted;
->return-typeReturn Type. Declare the return type of function using trailing-return-type; Can be omitted if no return value is required. We can also omit it when the return type can be easily deduced by compiler;
{statement}Function Body;
More About Capture List
[var]Capture var passed-by-value;
[=]Capture all variables in the father block;
[&var] Capture var passed-by-reference;
[&]Capture all variables in the father block;
[this]Explicitly capture “this” pointer;
[x, y, , ..., &]Capture all variables before ‘&’ by value, and all others by reference;