On Mon, Jan 14, 2013 at 5:43 AM, Igor R <boost.lists@gmail.com> wrote:
Hello,

I'm building my project with Android NDK toolchain (Boost1.51, GCC4.6
or GCC4.7), and I get the following error when trying to move thread.
Is there any workaround for this issue?

//...
vector_.push_back(boost::move(thread(&func, arg)));
//...

I believe you can only "boost::move" an lvalue. Aside from that, if you're using a C++03 std::vector, I don't think it'll be aware of the move semantics of boost::thread (just guessing on the types of your variables though, since you didn't spell them out), so I would expect this to trigger an error somewhere inside vector::push_back even if the move call compiled.

try.cpp:86:62: error: no matching function for call to 'move(boost::thread)'
try.cpp:86:62: note: candidates are:
In file included from boost/thread/detail/move.hpp:20:0,
                 from boost/thread/locks.hpp:11,
                 from boost/thread/pthread/mutex.hpp:12,
                 from boost/thread/mutex.hpp:16,
                 from boost/thread/pthread/thread_data.hpp:13,
                 from boost/thread/thread.hpp:17,
                 from boost/thread.hpp:13,
                 from try.h:3,
                 from try.cpp:6:
boost/move/move.hpp:324:97: note: template<class T> typename
boost::move_detail::disable_if<boost::has_move_emulation_enabled_aux<T>,
T&>::type boost::move(T&)
boost/move/move.hpp:324:97: note:   template argument
deduction/substitution failed:
boost/move/move.hpp: In substitution of 'template<class T> typename
boost::move_detail::disable_if<boost::has_move_emulation_enabled_aux<T>,
T&>::type boost::move(T&) [with T = boost::thread]':
try.cpp:86:62:   required from here
boost/move/move.hpp:324:97: error: no type named 'type' in 'struct
boost::move_detail::disable_if<boost::has_move_emulation_enabled_aux<boost::thread>,
boost::thread&>'
boost/move/move.hpp:330:96: note: template<class T> typename
boost::move_detail::enable_if<boost::has_move_emulation_enabled<T>,
boost::rv<T>&>::type boost::move(T&)
boost/move/move.hpp:330:96: note:   template argument
deduction/substitution failed:
boost/move/move.hpp: In substitution of 'template<class T> typename
boost::move_detail::enable_if<boost::has_move_emulation_enabled<T>,
boost::rv<T>&>::type boost::move(T&) [with T = boost::thread]':
try.cpp:86:62:   required from here
boost/move/move.hpp:330:96: error: no type named 'type' in 'struct
boost::move_detail::enable_if<boost::has_move_emulation_enabled<boost::thread>,
boost::rv<boost::thread>&>'

I'm a little surprised by this diagnostic (I would've thought has_move_emulation_enabled<boost::thread>::value == true); hmmm...
 
boost/move/move.hpp:336:96: note: template<class T> typename
boost::move_detail::enable_if<boost::has_move_emulation_enabled<T>,
boost::rv<T>&>::type boost::move(boost::rv<T>&)
boost/move/move.hpp:336:96: note:   template argument
deduction/substitution failed:
try.cpp:86:62: note:   'boost::thread' is not derived from 'boost::rv<T>'
In file included from boost/thread/detail/move.hpp:20:0,
                 from boost/thread/locks.hpp:11,
                 from boost/thread/pthread/mutex.hpp:12,
                 from boost/thread/mutex.hpp:16,
                 from boost/thread/pthread/thread_data.hpp:13,
                 from boost/thread/thread.hpp:17,
                 from boost/thread.hpp:13,
                 from try.h:3,
                 from try.cpp:6:
boost/move/move.hpp:943:6: note: template<class I, class O> O
boost::move(I, I, O)
boost/move/move.hpp:943:6: note:   template argument
deduction/substitution failed:
try.cpp:86:62: note:   candidate expects 3 arguments, 1 provided
In file included from boost/thread/locks.hpp:11:0,
                 from boost/thread/pthread/mutex.hpp:12,
                 from boost/thread/mutex.hpp:16,
                 from boost/thread/pthread/thread_data.hpp:13,
                 from boost/thread/thread.hpp:17,
                 from boost/thread.hpp:13,
                 from try.h:3,
                 from try.cpp:6:
boost/thread/detail/move.hpp:55:124: note: typename
boost::enable_if<boost::is_convertible<T&,
boost::detail::thread_move_t<T> >, boost::detail::thread_move_t<T>
>::type boost::move(T&) [with T = boost::thread; typename
boost::enable_if<boost::is_convertible<T&,
boost::detail::thread_move_t<T> >, boost::detail::thread_move_t<T>
>::type = boost::detail::thread_move_t<boost::thread>]
boost/thread/detail/move.hpp:55:124: note:   no known conversion for
argument 1 from 'boost::thread' to 'boost::thread&'

Oh, okay, I guess boost::thread has its own move emulation infrastructure distinct from Boost.Move :( Still, first comment above still applies.

In file included from boost/thread/locks.hpp:11:0,
                 from boost/thread/pthread/mutex.hpp:12,
                 from boost/thread/mutex.hpp:16,
                 from boost/thread/pthread/thread_data.hpp:13,
                 from boost/thread/thread.hpp:17,
                 from boost/thread.hpp:13,
                 from try.h:3,
                 from try.cpp:6:
boost/thread/detail/move.hpp:62:37: note: template<class T>
boost::detail::thread_move_t<T>
boost::move(boost::detail::thread_move_t<T>)
boost/thread/detail/move.hpp:62:37: note:   template argument
deduction/substitution failed:
try.cpp:86:62: note:   'boost::thread' is not derived from
'boost::detail::thread_move_t<T>'

HTH,

- Jeff