Boost C++ Libraries: Ticket #7619: Compiler error with move and packaged_task https://svn.boost.org/trac10/ticket/7619 <p> Consider the following simple code: </p> <pre class="wiki">// mt_test.cpp #include &lt;boost/asio.hpp&gt; #include &lt;boost/move/move.hpp&gt; #include &lt;boost/thread.hpp&gt; int process_data() { return 1; } int main() { boost::asio::io_service io_service; boost::asio::io_service::work work(io_service); boost::packaged_task&lt;int&gt; task(boost::bind(&amp;process_data)); io_service.post(boost::move(task)); } </pre><p> This generates the errors (using gcc version 4.6.3 and boost 1.51.0) </p> <pre class="wiki"> g++ -I ./boost_1_51_0/ mt_test.cpp -o mt_test In file included from ./boost_1_51_0/boost/asio/io_service.hpp:767:0, from ./boost_1_51_0/boost/asio/basic_io_object.hpp:19, from ./boost_1_51_0/boost/asio/basic_socket.hpp:19, from ./boost_1_51_0/boost/asio/basic_datagram_socket.hpp:20, from ./boost_1_51_0/boost/asio.hpp:20, from mt_test.cpp:2: ./boost_1_51_0/boost/asio/impl/io_service.hpp: In member function ‘void boost::asio::io_service::post(const CompletionHandler&amp;) [with CompletionHandler = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;]’: mt_test.cpp:18:34: instantiated from here ./boost_1_51_0/boost/asio/impl/io_service.hpp:95:67: error: no match for call to ‘(boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;) ()’ In file included from ./boost_1_51_0/boost/asio/detail/handler_invoke_helpers.hpp:21:0, from ./boost_1_51_0/boost/asio/detail/bind_handler.hpp:20, from ./boost_1_51_0/boost/asio/detail/wrapped_handler.hpp:18, from ./boost_1_51_0/boost/asio/io_service.hpp:24, from ./boost_1_51_0/boost/asio/basic_io_object.hpp:19, from ./boost_1_51_0/boost/asio/basic_socket.hpp:19, from ./boost_1_51_0/boost/asio/basic_datagram_socket.hpp:20, from ./boost_1_51_0/boost/asio.hpp:20, from mt_test.cpp:2: ./boost_1_51_0/boost/asio/handler_invoke_hook.hpp: In function ‘void boost::asio::asio_handler_invoke(Function, ...) [with Function = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;]’: ./boost_1_51_0/boost/asio/detail/handler_invoke_helpers.hpp:39:3: instantiated from ‘void boost_asio_handler_invoke_helpers::invoke(Function&amp;, Context&amp;) [with Function = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;, Context = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;]’ ./boost_1_51_0/boost/asio/detail/completion_handler.hpp:67:7: instantiated from ‘static void boost::asio::detail::completion_handler&lt;Handler&gt;::do_complete(boost::asio::detail::io_service_impl*, boost::asio::detail::operation*, const boost::system::error_code&amp;, std::size_t) [with Handler = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;, boost::asio::detail::io_service_impl = boost::asio::detail::task_io_service, boost::asio::detail::operation = boost::asio::detail::task_io_service_operation, std::size_t = long unsigned int]’ ./boost_1_51_0/boost/asio/detail/completion_handler.hpp:38:48: instantiated from ‘boost::asio::detail::completion_handler&lt;Handler&gt;::completion_handler(Handler&amp;) [with Handler = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;]’ ./boost_1_51_0/boost/asio/detail/impl/task_io_service.hpp:61:3: instantiated from ‘void boost::asio::detail::task_io_service::post(Handler) [with Handler = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;]’ ./boost_1_51_0/boost/asio/impl/io_service.hpp:97:3: instantiated from ‘void boost::asio::io_service::post(const CompletionHandler&amp;) [with CompletionHandler = boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;]’ mt_test.cpp:18:34: instantiated from here ./boost_1_51_0/boost/asio/handler_invoke_hook.hpp:64:3: error: no match for call to ‘(boost::detail::thread_move_t&lt;boost::packaged_task&lt;int&gt; &gt;) ()’ </pre><p> I thought this was solved in <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/4521"><span class="icon">​</span>Ticket 4521</a>? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7619 Trac 1.4.3 Ion Gaztañaga Wed, 31 Oct 2012 21:10:21 GMT owner, component changed https://svn.boost.org/trac10/ticket/7619#comment:1 https://svn.boost.org/trac10/ticket/7619#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Ion Gaztañaga</span> to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">move</span> → <span class="trac-field-new">threads</span> </li> </ul> <p> This seems a Boost.Thread related problem, as Boost.Thread has several move emulation modes. Changed component from Move to Thread to reflect this. </p> Ticket viboes Sat, 03 Nov 2012 01:21:11 GMT owner, status, component changed https://svn.boost.org/trac10/ticket/7619#comment:2 https://svn.boost.org/trac10/ticket/7619#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">threads</span> → <span class="trac-field-new">thread</span> </li> </ul> <p> I don't know if io_service.post accepts a Boost.Thread emulated rvalue reference. From the compiler error I will say that no. </p> <p> Boost.Thread allows to work with Boost.Move emulation when BOOST_THREAD_USES_MOVE is defined. If asio is Boost.Move compatible this could be an option. </p> <p> Anyway I don't think this is a bug with Boost.Thread. </p> Ticket viboes Sat, 03 Nov 2012 12:07:58 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7619#comment:3 https://svn.boost.org/trac10/ticket/7619#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket