C++ moves for people who don’t know or care what rvalues are 🏘️

Moves in C++ don’t require understanding of deep technical juju to get a grasp on.

Topher Winward
8 min readJan 17, 2019

When I was first learning about move semantics in C++, I kept reading articles that explained in terms of other scary sounding jargon — lvalues, rvalue references, memcpy, ownership. None of these things are strictly necessary to know about to understand the core of move semantics. (Though, the more you learn about them, the greater your understanding of move semantics will become.)

You may have heard of move semantics, and may know that they’re “faster”, but not why, or even how to move something. (Here “moves” and “move semantics” mean the same thing.)

This article will deliberately simplify or ignore some concepts (like constructors, rvalue references, stack vs heap) to make the core idea of moving easier to follow, so don’t worry if you already know this stuff and see something that isn’t technically correct. I’ll mark clarifications for these with a number. This article is aimed at those writing everyday (non-library) code, with little to no existing understanding of move semantics, to help get over the initial conceptual hurdle.

Now let’s look at the most important thing about moves in C++:

The most important thing about moves in C++ 🎉

#1: Moving a value doesn’t “move” anything.

--

--

Topher Winward

Joy finder and software developer. I design and develop software that helps people be as effective as they can be.