No, really, moving a return value is easy -- StackOverflow

People new to C++11 often hear about move semantics, and expect that they have to do work to take advantage of it. That's often not true, and often the cleanest, simplest code that doesn't even mention move or && anywhere is just what you want -- that's C++11, clean, safe, and faster than ever.

Perhaps the most common case (and question) involves returning values from functions. The new rule for modern C++ style: Just return even big objects by value, and move Just Happens.

It just came up again on StackOverflow:

C++11 rvalues and move semantics confusion

The link skips straight to Howard Hinnant's clear and correct answer.

Sometimes we just try too hard, because we expect efficient programming not to be easy. Welcome to C++11.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.