title: Does bind take value or reference of passed in non POD argument?
body: <p>I don't fully understand the meaning mentioned by <a href="http://www.boost.org/doc/libs/1_60_0/libs/bind/doc/html/bind.html#bind.limitations" rel="nofollow">boost bind limitations</a>.</p>
  
  <p>Imagine an instance of class <code>c</code> is constructed and its member function <code>start()</code> is called by a thread other than main thread.</p>
  
  <p>If my following understanding is wrong, please correct me:</p>
  
  <p>What <code>DoIt()</code> gets from its parameter <code>v</code> is a reference (that is, address) of vector.
  By the time <code>DoIt()</code> accesses variable <code>v</code>, its content can be already destroyed after <code>f()</code> returns. Therefore, the code</p>
  
  <pre><code>io_service.post(boost::bind(&amp;c::DoIt,this,v);
  </code></pre>
  
  <p>is unsafe and the program can crash. I should first serialize <code>v</code> in <code>f()</code> to std::string and pass it to <code>bind()</code> as argument instead, and change <code>DoIt()</code> to take std::string as parameter instead.</p>
  
  <pre><code>class c
  {
      boost::asio::io_service io_service;
      void DoIt(std::vector&lt;int&gt; v){
          std::cout &lt;&lt; v.size() &lt;&lt; std::endl;
      }
      void start(){
          io_service.run();
      }
      void f(){
          std::vector&lt;int&gt; v;
          v.push_back(1);
          v.push_back(2);
          io_service.post(boost::bind(&amp;c::DoIt,this,v);
      }
  }
  </code></pre>
  
  <p>Best regards,</p>