Manoj Rao bio photo

Manoj Rao

Your Average Common Man

Email Twitter Github

I’m just keeping this here to remind myself that std::move() doesn’t have to be complex, mind-numbing activity.

Here’s Herb Sutter’s post on getting away with minimal, necessary understanding of move semantics to not be afraid of it.

"In C++, copying or moving from an object a to an object b sets b to a’s
original value.
The only difference is that copying from a won’t change a, but moving from a
might.

To pass a named object a as an argument to a && “move” parameter (rvalue
reference parameter), write std::move(a). That’s pretty much the only time you
should write std::move, because C++ already uses move automatically when copying
from an object it knows will never be used again, such as a temporary object or
a local variable being returned or thrown from a function.

That’s it."

Interestingly enough, there is a page or two’s worth of “advanced” explanation. Then, several pages worth FAQ style explanation. Herb Sutter is the secretary or chair of C++ standards committee. His job requires him to understand all the details of the language implementation, but, do I? Am I simply learning the flaw of a draconian language struggling to keep pace with the sleeker, yuppier, new-age competitors?


My Podcast!

If you like topics such as this then please consider subscribing to my podcast. I talk to some of the stalwarts in tech and ask them what their favorite productivity hacks are:

Available on iTunes Podcast

Visit Void Star Podcast’s page on iTunes Podcast Portal. Please Click ‘Subscribe’, leave a comment.

Get it iTunes