title: segfault when assigning an std::thread to a vector<std::thread>
body: <p>This segfaults:</p>
  
  <pre><code>std::vector&lt;std::thread&gt;    _pool;
  State &amp;                     _state;
  
  ...
  
  for(uint32_t n = 0; n &lt; nThreads; ++n)
      _pool[n]  = std::thread(_thFunction, std::ref(_state));
  </code></pre>
  
  <p>This does not:</p>
  
  <pre><code>std::vector&lt;std::thread&gt;    _pool;
  State &amp;                     _state;
  
  ...
  
  for(uint32_t n = 0; n &lt; nThreads; ++n)
      _pool.push_back( std::thread(_thFunction, std::ref(_state)) );
  </code></pre>
  
  <p>The difference in the use of push_back to the vector instead of using assignment to a specific entry in the vector.</p>
  
  <p>_thFunction is an std::function.</p>
  
  <p>When I apply a pool.reserve(10) to the first block of code, I still get a segfault on the first assignment.</p>
  
  <p>I suspect that this is related to move semantics, but I'm not sure.  What's going on here?</p>
  
  <p>A stacktrace from gdb seems to indicate a null this pointer:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x00000000004092e5 in std::thread::joinable (this=0x0) at /usr/include/c++/4.8.3/thread:162
  162     { return !(_M_id == id()); }
  (gdb) backtrace
  #0  0x00000000004092e5 in std::thread::joinable (this=0x0) at /usr/include/c++/4.8.3/thread:162
  #1  0x000000000040927a in std::thread::operator=(std::thread&amp;&amp;) (this=0x0, 
      __t=&lt;unknown type in /home/stackuser/src/dsl/build/debug/server/dsl, CU 0x0, DIE 0x37b88&gt;)
      at /usr/include/c++/4.8.3/thread:150
  #2  0x000000000041350d in ThreadPool&lt;std::function&lt;void (State&amp;)&gt; &gt;::ThreadPool(State&amp;, unsigned int, std::function&lt;void (State&amp;)&gt;) (this=0x69aed0, state=..., nThreads=2, thFunction=...)
      at src/server/ThreadPool.h:38
  #3  0x0000000000408405 in Application::Application (this=0x6946e0) at src/server/Application.cpp:69
  #4  0x0000000000455594 in Singleton&lt;Application&gt;::CreateInstance () at src/server/Singleton.h:12
  #5  0x0000000000454997 in main (argc=1, argv=0x7fffffffdc98) at src/server/main.cpp:85
  </code></pre>