move semantics

Move semantics is a feature added in C++11 to allow efficient transfer of values by allowing “destructive” copying in cases where the source’s lifetime is almost up.

When move semantics were introduced in C++11, it sparked a lot of discussion about how to pass arguments to functions that will take a copy of the argument value (for example, the “set” half of get/set functions). That confusion seemed to subside when the “by value by default” suggestion started to make the rounds, but in his CppCon2014 talk, Herb Sutter set off a whole new round of debate. Sutter makes two arguments for why “by const-ref by default” is the best rule. I don’t buy them. Continue Reading