tags:

views:

171

answers:

2
  1. What it is?
  2. What it does?
  3. When it should be used?

Good links are appreciated.

+3  A: 

move from Bjarne Stroustrup

DumbCoder
A very good link, but I won't upvote this until it is wrapped in some sentence. Call me a grammar-nazi, but i loooove words :)
ereOn
@ereOn: A agree, some more words would make this nicer. But sometimes the content of the package is more valuable that the wrapping. +1 from me for both your comment and the answer.
John
@John: There is no content in this post. Just a link to where you might find the actual content you're looking for. It is common SO etiquette to put the answer *here* in the answer itself, not just refer to something someone else wrote elsewhere on the internet. External webpages may not exist tomorrow, when a new reader sees this question. It is also needlessly hard to get an overview of the answers when every one of them is a link to some external page. Post a summary *here* so people can see it. Until then, -1 for not providing an answer
jalf
Look at @Scharron's answer, which has external links, but *also* provides a summary here for people to read. That is a much better way to do it.
jalf
@jalf When you concise a whole page into 3-4 sentences you will miss out on the nuances of the whole answer and probably come up with a half correct/half wrong answer. Better give the user the full answer or none at all. And if you go the standards website they have all docs from the past 20 years, I went till that. Mind checking it ?
DumbCoder
@jalf: Fair enough. I agree.
John
@DumbCoder: Missing out on nuances is a lot better than missing out on *everything*. Yes, you can find *all* the information on the internet. But then every SO answer could be replaced with a "just Google it". Not helpful. And not "better". Better is to write a summary so the reader has a basic idea of what it is, and then provide a link if he/she wants to understand all the nuances.
jalf
@jalf - Missing on nuances is not better. You probably haven't heard from Michelangelo - "Trifles make perfection, and perfection is no trifle". If you have visited gotw.ca, many questions seem like nuances, but they make good programmers not good reading material.
DumbCoder
Or we can look at it another way. When this answer is upvoted, it gives you rep. It indicates that you are knowledgeable and have contributed to the community. But what have you contributed? You haven't written a single word of information in this answer. So you don't deserve any rep for it. If Stroustrup was on SO, *he* would be the one deserving the rep.In order to deserve rep, *you* need to make the contribution.Then there's the problem with external links in general. SO is trying to provide the best answers to every programming answer...
jalf
...The best answer is the one I can read without clicking any links. And when someone finds the question 6 months from now, will your link still work? Will it still point to the same page? Will the page still contain the same information?External links are fine, but you can't *rely* on them. The answer should be *here*, where the question is.
jalf
@DumbCoder: *every* answer leaves out nuances. The page you linked to leaves out nuances. It is up to the answerer to decide *which* details to leave out. Also, I don't know where you got the "3-4 sentences" limit from. There is no length limit on answer. Write as many details as you like.
jalf
Concising(wording in my own words) an article/standard document would make me knowledgeable ? I don't think so, unless I know how to use it and have explored it in my coding, which seems little difficult looking at the vastness and ever increasing language features of C++. And regarding Stroustrup's bit, all points garnered by anybody on SO for C++ should ultimately be dedicated to him.
DumbCoder
As for Michelangelo, no, I haven't heard from him recently. But Saint-Exupery would like a chat with him: "A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away"
jalf
by the way, it would have been a lot easier for you to just write an answer that everyone found useful than to continually justify *not* doing so. ;)
jalf
+5  A: 

http://en.wikipedia.org/wiki/C%2B%2B0x#Rvalue_reference_and_move_semantics
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html#Move_Semantics

  1. std::move() is the c++0x way to use move semantics.
  2. It converts its argument to a rvalue (Type&&)
  3. To move objects

It's a new c++ way to avoid copies. For example, using a move constructor, a vector could just copy its internal pointer to data to the new object, leaving the moved object in an incorrect state, avoiding to copy all data. This would be c++-valid.

Try googling for move semantics, rvalue, perfect forwarding.

Scharron
Move-semantics require the moved object remain *valid*, which is not an incorrect state. (Rationale: It still has to destruct, make it work.)
GMan