C/C++ Arena

Step 1 of 7

Copies are expensive

Copying a std::vector with a million elements copies a million elements. But often the source is about to disappear anyway (a temporary, or a variable you're done with). In that case you can steal its internals instead: that's a move.

std::move(x) doesn't move anything by itself. It casts x to an rvalue, which says "I'm done with x, you may steal from it".

After a move, the source is in a valid but unspecified state. Don't read its value; you may assign a new one.

Your turn: move big into store instead of copying it.

Next: Write a move constructor