I\'ve encountered a notation like:
int x = 4;
auto y = [&r = x, x = x+1]()->int {
r += 2;
return x+2;
}();
Can you explain
This example is part of C++14 feature "Lambda capture Initializers", This allows creating lambda captures initialized with arbitrary expressions. Using this reference-captures can have different names than the referenced variable.
If you run your code :
int x = 4;
auto y = [&r = x, x = x+1]()->int {
r += 2; //r=6
return x+2;//5+2
};
cout<