title: Why is std::packaged_task<void()> not valid?
body: <p>Using MSVC2012,</p>
  
  <p>The following code will compile and run as expected</p>
  
  <pre><code>std::packaged_task&lt; int() &gt; task( []()-&gt;int{ std::cout &lt;&lt; "hello world" &lt;&lt; std::endl; return 0; } );
  std::thread t( std::move(task) );
  t.join();
  </code></pre>
  
  <p>while the following code will fail to compile and run</p>
  
  <pre><code>std::packaged_task&lt; void() &gt; task( [](){ std::cout &lt;&lt; "hello world" &lt;&lt; std::endl; } );
  std::thread t( std::move(task) );
  t.join();
  </code></pre>
  
  <p>Why is this so?</p>
  
  <p>Edit:
  As a workaround, it is possible to use std::promise to get a std::future on a function that returns void</p>
  
  <pre><code>std::promise&lt;void&gt; promise;
  auto future = promise.get_future();
  std::thread thread( [](std::promise&lt;void&gt; &amp;p){ std::cout &lt;&lt; "hello world" &lt;&lt; std::endl; p.set_value(); }, std::move(promise) );
  future.wait();
  </code></pre>
  
  <p>Note that there is a bug in the vs2012 library with std::thread that forces you to pass the promise in as a l-value reference and move the promise in, it would not compile if you pass the promise by value or by r-value reference. This is supposedly because the implementation uses std::bind() which does not behave as expected.</p>