unique_future without rvalue references
I'm using Clang on the Mac without the C++11 dialect enabled in this project. With BOOST_NO_RVALUE_REFERENCES defined, in Boost 1.49, how can I write a function returning an object of type unique_future<T> ? I tried changing std::move to boost::move which I expected to work. I tried fiddling with thread_move_t explicitly. I can't get anything to work. What's the magic formula?
Le 16/05/12 06:13, John M. Dlugosz a écrit :
I'm using Clang on the Mac without the C++11 dialect enabled in this project. With BOOST_NO_RVALUE_REFERENCES defined, in Boost 1.49, how can I write a function returning an object of type unique_future<T> ? I tried changing std::move to boost::move which I expected to work. I tried fiddling with thread_move_t explicitly. I can't get anything to work.
What's the magic formula?
Hi, Boost.Thread move semantic emulation up to 1.49 has many problems. I have reworked the move semantic interfaces adapting them to Boost.Move in trunk (I hope it will be released for 1.50). If you can not use the trunk, have you tried with boost::unique_future<T> f() { /// x return boost::detail::thread_move_t<T>(x); } Best, Vicente
On 5/16/2012 3:45 AM, Vicente J. Botet Escriba wrote:
Le 16/05/12 06:13, John M. Dlugosz a écrit :
If you can not use the trunk,
have you tried with
boost::unique_future<T> f() { /// x return boost::detail::thread_move_t<T>(x); }
Best, Vicente
Yes, I tried that. I get an error about no viable constructor. I tried the form you show (prefix operator form) and an explicit operator syntax call.
On 5/16/2012 3:45 AM, Vicente J. Botet Escriba wrote:
have you tried with
boost::unique_future<T> f() { /// x return boost::detail::thread_move_t<T>(x); }
Writing it as two lines,
boost::detail::thread_move_t<T> shuttle (x);
return shuttle;
it's clear that the error is with the return statement. It insists that the copy
constructor is callable, even though in reality it is optimized out. That is what the
standard says. Perhaps other compilers ignore that fine print.
Yet, packaged_task::get_future seems to be able to return just fine.
Writing it as:
boost::detail::thread_move_t
Le 16/05/12 20:17, John M. Dlugosz a écrit :
On 5/16/2012 3:45 AM, Vicente J. Botet Escriba wrote:
have you tried with
boost::unique_future<T> f() { /// x return boost::detail::thread_move_t<T>(x); }
Writing it as two lines, boost::detail::thread_move_t<T> shuttle (x); return shuttle;
it's clear that the error is with the return statement. It insists that the copy constructor is callable, even though in reality it is optimized out. That is what the standard says. Perhaps other compilers ignore that fine print.
Yet, packaged_task::get_future seems to be able to return just fine.
Writing it as:
boost::detail::thread_move_t
shuttle (future_result); return unique_future<RetType>(shuttle); seems to work! Yea! Odd, I had tried the explicit construct around the operator all on one line yesterday, and it didn't help.
Could you try with trunk? Vicente
participants (2)
-
John M. Dlugosz
-
Vicente J. Botet Escriba