Note that there are some explanatory texts on larger screens.

plurals
  1. POC++, Linux: error: conversion from ‘boost::unique_future<void>’ to non-scalar type ‘boost::shared_future<void>’ requested. how to get around it?
    primarykey
    data
    text
    <p>I try to work with <a href="http://www.boost.org/doc/libs/1_47_0/doc/html/thread/synchronization.html#thread.synchronization.futures" rel="nofollow">boost thread futures</a>. So as shown <a href="http://boost.2283326.n4.nabble.com/Reviews-Futures-packaged-task-and-shared-future-td2653185.html" rel="nofollow">here</a> we can get <a href="http://www.boost.org/doc/libs/1_47_0/doc/html/thread/synchronization.html#thread.synchronization.futures.reference.shared_future" rel="nofollow">shared future</a> from <a href="http://www.boost.org/doc/libs/1_47_0/doc/html/thread/synchronization.html#thread.synchronization.futures.reference.packaged_task" rel="nofollow">packaged task</a>.</p> <p>So I try such function on linux:</p> <pre><code>template &lt;class task_return_t&gt; void pool_item( boost::shared_ptr&lt; boost::packaged_task&lt;task_return_t&gt; &gt; pt) { boost::shared_future&lt;task_return_t&gt; fi= pt-&gt;get_future(); // error //... </code></pre> <p>but I get error calling it:</p> <pre><code>../../src/cf-util/thread_pool.h: In member function ‘void thread_pool::pool_item(boost::shared_ptr&lt;boost::packaged_task&lt;R&gt; &gt;) [with task_return_t = void]’: ../../src/cf-util/thread_pool.h:64:3: instantiated from ‘void thread_pool::post(boost::shared_ptr&lt;boost::packaged_task&lt;R&gt; &gt;) [with task_return_t = void]’ ../../src/cf-server/server.cpp:39:27: instantiated from here ../../src/cf-util/thread_pool.h:124:58: error: conversion from ‘boost::unique_future&lt;void&gt;’ to non-scalar type ‘boost::shared_future&lt;void&gt;’ requested </code></pre> <p>I did not take any futures from that task before. <a href="http://code.google.com/p/cloudobserver/source/browse/trunk/CloudServer/" rel="nofollow">all source code</a>, <a href="http://code.google.com/p/cloudobserver/source/browse/trunk/CloudServer/src/cf-server/server.cpp?r=1477" rel="nofollow">place where I do call from</a>, <a href="http://code.google.com/p/cloudobserver/source/browse/trunk/CloudServer/src/cf-util/thread_pool.h?r=1477" rel="nofollow">my thread pool that is being called</a>. And on Windows under Visual Studio 2010 it compiles and works perfectly.</p> <p>What shall I do? how to fix or get around this error?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload