Extend C++0x lambda syntax with moves
I propose using the -> specifier on the lambda capture list which makes it behave like the = specifier except it moves data instead of copying it. Also, I'd recommend not allowing this to be defaultable since it's kind of dangerous.
vector v = { 1, 2, 3, 4, 5 };
// moves v into the lambda instead of copying it
[->v] mutable { v.push_back(6); }
5
votes
1 comment
-
George
commented
I don't think anybody wants Microsoft to come up with nonstandard solutions, they already doing it too much. This suggestion should be directed to the C++ standardization committee.