Boost logo

Boost Users :

Subject: Re: [Boost-users] [Thread] Can't compile package_task code with 1.54
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-06-01 02:06:48


Le 01/06/13 07:30, Vicente J. Botet Escriba a écrit :
> Le 01/06/13 00:56, Szymon Gatner a écrit :
>> Hi,
>>
>> I just tried to compile my 1.52- based code with 1.54 beta and run
>> into package_task compilation issue.
>>
>> In 1.52 I was using BOOST_THREAD_VERSION=3 define but with 1.54 I
>> complied with =4.
>>
>> Test program:
>>
>> #define BOOST_THREAD_VERSION 4
>>
>> #include <boost/thread/future.hpp>
>> #include <boost/function.hpp>
>>
>> struct MyFunc
>> {
>> void operator()()const {}
>> };
>>
>> int main()
>> {
>> boost::function<void()> f;
>> MyFunc mf;
>>
>> boost::packaged_task<void()> t1(f); // error 1
>> boost::packaged_task<void()> t2(mf); // error 2
>> }
>>
>>
>> error 1 being:
>>
>> d:\devel\boost_1_54_0_beta1\boost\thread\future.hpp(2848): error
>> C2664:
>> 'boost::detail::task_object<F,R>::task_object(boost::detail::task_object<F,R>
>> &)' : cannot convert parameter 1 from 'boost::function<Signature>' to
>> 'boost::detail::task_object<F,R> &'
>>
>> and error 2 similarly:
>>
>> d:\devel\boost_1_54_0_beta1\boost\thread\future.hpp(2848): error
>> C2664:
>> 'boost::detail::task_object<F,R>::task_object(boost::detail::task_object<F,R>
>> &)' : cannot convert parameter 1 from 'MyFunc' to
>> 'boost::detail::task_object<F,R> &'
>>
>> (I tried with custom functor because I thought maybe error was
>> related to boost function)
>>
>> Compiling with Visual Studio 2012 Update 3
>>
>>
> Hi,
>
> this is related to https://svn.boost.org/trac/boost/ticket/8596 which
> is fixed now, but maybe it doesn't works for you.
> Note that the trunk regression test since revision 84414 run with this
> compiler pass (
> libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp)
> <https://svn.boost.org/trac/boost/browser/branches/release/libs/thread/test/sync/futures/packaged_task/func_ctor_pass.cpp?rev=84468>
> http://www.boost.org/development/tests/trunk/developer/thread.html.
>
> Unfortunately not a single msvc tester has run after revision 84468 on
> release branch.
>
> I have no the possibility to reproduce it now. Please could you send
> the whole log? (privately if you prefer? Or via a ticket?
>
I have found the error. My tests don't test for packaged_task<void()>.

The following patch should fix the issue (see attached file)

Please could you apply it a tell me if it fix with your compiler?

Best,
Vicente

  svn diff future.hpp
Index: future.hpp
===================================================================
--- future.hpp (revision 84547)
+++ future.hpp (working copy)
@@ -2362,18 +2362,12 @@
            task_object(task_object&);
          public:
              F f;
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::forward<F>(f_))
- {}
-#else
              task_object(F const& f_):
                  f(f_)
              {}
              task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::move(f_)) // TODO forward
+ f(boost::move(f_))
              {}
-#endif

  #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &&
defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
              void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
@@ -2616,18 +2610,12 @@
            task_object(task_object&);
          public:
              F f;
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::forward<F>(f_))
- {}
-#else
              task_object(F const& f_):
                  f(f_)
              {}
              task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::move(f_)) // TODO forward
+ f(boost::move(f_))
              {}
-#endif

  #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &&
defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
              void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net