title: Why doesn't future::wait() block
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;thread&gt;
  #include &lt;future&gt;
  
  
  int main()
  {
      auto pms = std::promise&lt;std::string&gt;();
      auto ftr = pms.get_future();
  
      std::thread([&amp;](){pms.set_value("hello world");});    
      ftr.wait();
      std::cout &lt;&lt; ftr.get() &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>According to <a href="http://en.cppreference.com/w/cpp/thread/future/wait" rel="nofollow noreferrer">this link</a>, <code>std::future::wait</code> blocks until the result becomes avaiable.<br></p>
  
  <p>However, the code above can't print anything. Obviously the main thread has finished before the thread of <code>pms.set_value</code> finished.<br></p>
  
  <p>Why doesn't <code>ftr.wait()</code> block?</p>