Quick Q: Why pass by value then move? -- StackOverflow
Quick A: Because it's a new C++11 parameter passing pattern, also recently mentioned as part of GotW #4.
Why do we copy then move?
I saw code somewhere in which someone decided to copy an object and subsequently move it to a data member of a class. This left me in confusion in that I thought the whole point of moving was to avoid copying. Here is the example:
struct S { S(std::string str) : data(std::move(str)) {} };Here are my questions:
- Why aren't we taking an rvalue-reference to
str?- Won't a copy be expensive, especially given something like
std::string?- What would be the reason for the author to decide to make a copy then a move?
- When should I do this myself?

Note: This updated working draft contains all of the updates approved at the Bristol ISO C++ meeting to make this the C++14 Committee Draft. Today our project editor Stefanus Du Toit, wth the kind help of Jonathan Wakely and our editorial committee of Daniel Kruegler, Alisdair Meredith, Mike Miller, and Richard Smith, finished applying and verifying the updates voted in at Bristol. This document has now been transmitted to SC22 for circulation for C++14's primary international comment ballot.
The C++Now 2013 conference is still in flight, but presentation materials are being made available online as the conference progresses. You can find them here in their GitHub repository: