title: How to use move semantics with std::string during function return?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4986673/c11-rvalues-and-move-semantics-confusion">C++11 rvalues and move semantics confusion</a>  </p>
  </blockquote>
  
  
  
  <p>What I think is correct is</p>
  
  <pre><code>std::string GetLine()
  {
  std::string str;
  std::getline(std::cin, str);
  return std::move(str);
  }
  </code></pre>
  
  <p>But at this link <a href="http://www.cprogramming.com/c++11/rvalue-references-and-move-semantics-in-c++11.html" rel="noreferrer">http://www.cprogramming.com/c++11/rvalue-references-and-move-semantics-in-c++11.html</a>
  ( check the header part Returning an explicit rvalue-reference from a function)</p>
  
  <p>which is #1 google search hit for move semantics shows a similar function signature as </p>
  
  <pre><code>int&amp;&amp; GetInt()
  {
  int x = 0;
  // code here
  return std::move(x);
  }
  </code></pre>
  
  <p>From what I read at other places &amp;&amp; means rvalue <strong>reference</strong> so in this case its returning a reference to an object that doesn't exist.  </p>
  
  <p>So which is it?</p>
  
  <p>(Yes I know moving an int has no real benifit but the question is whether to use the return type of std::string or std::string&amp;&amp; in the first function.  And if that is how it should be done for all types.)</p>