title: Avoiding copy of objects with the "return" statement
body: <p>I have a very basic question in C++.
  How to avoid copy when returning an object ?</p>
  
  <p>Here is an example :</p>
  
  <pre><code>std::vector&lt;unsigned int&gt; test(const unsigned int n)
  {
      std::vector&lt;unsigned int&gt; x;
      for (unsigned int i = 0; i &lt; n; ++i) {
          x.push_back(i);
      }
      return x;
  }
  </code></pre>
  
  <p>As I understand how C++ works, this function will create 2 vectors : the local one (x), and the copy of x which will be returned. Is there a way to avoid the copy ? (and I don't want to return a pointer to an object, but the object itself)</p>
  
  <hr>
  
  <p>What would be the syntax of that function using "move semantics" (which was stated in the comments)?</p>