[] () mutable throw() -> int {
return 5;
}
[]
: Capture clause. Specifies what variables are captured from the environment.&
are passed by reference, otherwise they are passed by value[&]
: All variables are captured by reference[=]
: All variables are captured by value[=, &var]
, capture all variables by value, capture "var" by reference[&, &i]
has &i
repeated()
: Parameter list. Optional. Used like a normal function's parameter list.mutable
: Mutable specification. Optional. Allows capture by value variables to be modified inside the lambda's body.throw(...)
: Exception specification. Optional.noexcept
or throw()
means no exception is thrownthrow(...)
if an exception of any type can be thrownthrow(type)
if an exception of type type
can be thrown-> int
: Trailing return type. Optional. Defaults to auto
{ ... }
: Lambda bodyFor more information: Microsoft Docs.