title: Boost threads - passing parameters by reference
body: <p>My application has a section that resembles the following code</p>
  
  <pre><code>void SomeClass::OtherMethod(std::vector&lt;std::string&gt;&amp; g)
  {
    g.pushback("Something");
  }
  
  void SomeClass::SomeMethod()
  {
    std::vector&lt;std::string&gt; v;
    boost::thread t(boost::bind(&amp;SomeClass::OtherMethod,this,v)
    t.join();
    std::cout &lt;&lt; v[0]; //Why is this empty when the vector created on stack
  }
  </code></pre>
  
  <p>I wanted to know why the vector v is empty when the vector is created on the stack and it works when it is created on the heap. I was expecting the above code to work since the vector remains in scope even when it is created on the stack.</p>