Koenig explains std::move as, well, just a bit of a fib, really:
Sometimes You Must Violate an Abstraction to Maintain It
by Andrew Koenig
From the article:
What
std::movereally does is to return its argument as an rvalue reference. In effect, every time we usestd::move, we are telling a lie. In this case, by writingstd::move(t.s), we are saying that we want to uset.s, but to do so in a way that treatst.sas an rvalue. It is acceptable for us to tell this lie for exactly the same reason that it is acceptable for us to castt.stostring&&in the previous example: We know thatt.sis a member oft, andtreally refers to an rvalue in our caller's context.We can tell such lies any time we are willing to take responsibility for the consequences. ...

Add a Comment
Comments are closed.