title: How to return a class member vector in c++11
body: <p>I read a couple of posts on how to return a vector from a method include these ones:</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/4986673/c11-rvalues-and-move-semantics-confusion-return-statement">c11 rvalues and move semantics confusion return statement</a></p></li>
  <li><p><a href="https://web.archive.org/web/20130930101140/http://cpp-next.com/archive/2009/08/want-speed-pass-by-value" rel="noreferrer">want speed pass by value</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/25963685/why-does-visual-studio-not-perform-return-value-optimization-rvo-in-this-case">why does visual studio not perform return value optimization rvo</a></p></li>
  <li><p><a href="http://en.wikipedia.org/wiki/Return_value_optimization" rel="noreferrer">Wiki - Return Value Optimization</a></p></li>
  </ol>
  
  <p>and I'm still confused on how to pass a vector the right way in VS2013 and what are the differences between the following methods in this code(the questions are marked in the comments):</p>
  
  <pre><code>class Foo{
   private:
     std::vector&lt;int&gt; vect;
  
   public:
       //1 - classic way?
      void GetVect(std::vector&lt;int&gt;&amp; v)
        {
           v = vect;// assignment with swap?
        }
  
      //2 - RVO?
      std::vector&lt;int&gt; GetVect()
        {
          return vect;
        } 
  
      //3 - RVO with const?
      std::vector&lt;int&gt; GetVect() const
        {
          return vect;
        }
  
      //4 - just move?
      std::vector&lt;int&gt; GetVect() 
        {
          return std::move(vect);
        }  
  
       //5 - move with {}?
      std::vector&lt;int&gt; GetVect() 
        {
          return { std::move(vect) };
        }  
   }
  </code></pre>
  
  <p>So I m not sure if //1 is an explicit form of //2, not sure if 3 works. What are the differences between 4 and 5? How to test it if RVO works for vectors in VS2013? </p>