title: STL containers move semantics and return by value: how many times of copying get avoided away?
body: <p>I know that in c++11 the move semantics have been implemented in the STL containers to avoid temporary objects. And people say that now it's perfect to write functions which return by value. But I have some confusions about on earth how many times of copying are actually get avoided. Please see the following example:</p>
  
  <pre><code>vector&lt;int&gt; myVector() {
      vector&lt;int&gt; res;
      res.push_back(4);
      res.push_back(5);
      return res;
  }
  
  vector&lt;int&gt; v = myVector(); 
  </code></pre>
  
  <p>My understanding is that in c++03, <code>myVector</code> returns a copy of <code>res</code>( <code>4</code>, <code>5</code> copied once), when evaluating <code>vector&lt;int&gt; v = myVector();</code> <code>vector&lt;int&gt;</code>'s copy constructor <code>vector&lt;int&gt;(const vector&lt;int&gt; &amp;)</code> is invoked ( <code>4</code>, <code>5</code> copied twice). However in c++11 with move semantics, I want to know which copy of <code>4</code> and <code>5</code> gets avoided? both? Is return value optimization also invoked to reduce one time of copying <code>4</code> and <code>5</code>? </p>