title: How to improve std::vector parameter passing (move semantics?)
body: <p>It seems that I cannot completely understand move semantics: I want to fill an <code>std::vector</code> (member of a class) from an external function. Currently, I have something like:</p>
  
  <pre><code>void fillVector(MyClass &amp; myclass) {
      std::vector&lt;int&gt; vec;
      /* Filling vec */
      // ...
      myclass.setVector(vec);
  }
  
  class MyClass {
      public:
           setVector(const std::vector&lt;int&gt; &amp; v) { v_ = v;}
      private:
           std::vector&lt;int&gt; v_;
  };
  
  int main() {
      MyClass myclass;
      fillVector(myclass);
      /* Use myclass.v_ somehow */.
  }
  </code></pre>
  
  <p>I had this code for a long time, and it works fine. Now, I cannot understand how it works since I am asigning a reference to a vector which will be destroyed. My questions are:</p>
  
  <ol>
  <li>How is this code able to work?</li>
  <li>What is the best way to implement <code>fillVector</code> and <code>MyClass::setVector()</code>? I think that can be done with move semantics but I cannot figure out how.</li>
  </ol>
  
  <p>Thank you!</p>