I suggest you ...

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
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    asdfasdf shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • GeorgeGeorge commented  ·   ·  Flag as inappropriate

        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.

      Feedback and Knowledge Base