[thread][move] compiling move(thread) with Android NDK GCC4.7

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))); //... 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>&>' 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&' 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>'

Le 14/01/13 14:43, Igor R a écrit :
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))); //... How is vector_ declared?
Best, Vicente

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))); //...
How is vector_ declared?
std::vector<boost::thread> but even without push_back() it fails to compile.

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

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.
I forgot to mention, but the above code compiles under MSVC10 and iOS gcc toolchain...

On Mon, Jan 14, 2013 at 9:57 AM, Igor R <boost.lists@gmail.com> wrote:
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.
I forgot to mention, but the above code compiles under MSVC10 and iOS gcc toolchain...
...which have rvalue references? - Jeff

I forgot to mention, but the above code compiles under MSVC10 and iOS gcc toolchain...
...which have rvalue references?
Yes, you're right, it turns out that while the above compilers have c++11 enabled by default, in ndk gcc4.7 it's disabled by default...

On Wed, Jan 16, 2013 at 1:27 AM, Igor R <boost.lists@gmail.com> wrote:
I forgot to mention, but the above code compiles under MSVC10 and iOS gcc toolchain...
...which have rvalue references?
Yes, you're right, it turns out that while the above compilers have c++11 enabled by default, in ndk gcc4.7 it's disabled by default...
One suggestion: lobby for Boost.Thread to adopt Boost.Move rather than its own internal move emulation machinery (or, better yet, supply a patch!), and additionally use the Boost.Container data structures, which are Boost.Move-aware AFAIK. - Jeff

Le 16/01/13 18:38, Jeffrey Lee Hellrung, Jr. a écrit :
On Wed, Jan 16, 2013 at 1:27 AM, Igor R <boost.lists@gmail.com <mailto:boost.lists@gmail.com>> wrote:
>> I forgot to mention, but the above code compiles under MSVC10 and iOS >> gcc toolchain... > > > ...which have rvalue references?
Yes, you're right, it turns out that while the above compilers have c++11 enabled by default, in ndk gcc4.7 it's disabled by default...
One suggestion: lobby for Boost.Thread to adopt Boost.Move rather than its own internal move emulation machinery (or, better yet, supply a patch!), and additionally use the Boost.Container data structures, which are Boost.Move-aware AFAIK.
Boost.Thread make use of Boost.Move when BOOST_THREAD_USES_MOVE is defined and can be used with Boost.Container or any standard c++ container. The problem is that it doesn't provides both emulations at once. Vicente

On Wed, Jan 16, 2013 at 10:06 AM, Vicente J. Botet Escriba < vicente.botet@wanadoo.fr> wrote:
Le 16/01/13 18:38, Jeffrey Lee Hellrung, Jr. a écrit :
On Wed, Jan 16, 2013 at 1:27 AM, Igor R <boost.lists@gmail.com> wrote:
I forgot to mention, but the above code compiles under MSVC10 and iOS gcc toolchain...
...which have rvalue references?
Yes, you're right, it turns out that while the above compilers have c++11 enabled by default, in ndk gcc4.7 it's disabled by default...
One suggestion: lobby for Boost.Thread to adopt Boost.Move rather than its own internal move emulation machinery (or, better yet, supply a patch!), and additionally use the Boost.Container data structures, which are Boost.Move-aware AFAIK.
Boost.Thread make use of Boost.Move when BOOST_THREAD_USES_MOVE is defined and can be used with Boost.Container or any standard c++ container. The problem is that it doesn't provides both emulations at once.
Remind me what the limitation of Boost.Move's emulation are wrt Boost.Thread, and how Boost.Thread's internal emulation avoids that limitation? - Jeff

Le 17/01/13 03:34, Jeffrey Lee Hellrung, Jr. a écrit :
On Wed, Jan 16, 2013 at 10:06 AM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr <mailto:vicente.botet@wanadoo.fr>> wrote:
Le 16/01/13 18:38, Jeffrey Lee Hellrung, Jr. a écrit :
On Wed, Jan 16, 2013 at 1:27 AM, Igor R <boost.lists@gmail.com <mailto:boost.lists@gmail.com>> wrote:
>> I forgot to mention, but the above code compiles under MSVC10 and iOS >> gcc toolchain... > > > ...which have rvalue references?
Yes, you're right, it turns out that while the above compilers have c++11 enabled by default, in ndk gcc4.7 it's disabled by default...
One suggestion: lobby for Boost.Thread to adopt Boost.Move rather than its own internal move emulation machinery (or, better yet, supply a patch!), and additionally use the Boost.Container data structures, which are Boost.Move-aware AFAIK.
Boost.Thread make use of Boost.Move when BOOST_THREAD_USES_MOVE is defined and can be used with Boost.Container or any standard c++ container. The problem is that it doesn't provides both emulations at once.
Remind me what the limitation of Boost.Move's emulation are wrt Boost.Thread, and how Boost.Thread's internal emulation avoids that limitation?
You misunderstood my concern. Boost.Move has no specific limitations with respect to Boost.Thread. Boost.Thread internal(old) emulation has more troubles than the one provided by Boost.Move. I forgot to tell that BOOST_THREAD_USES_MOVE is defined by default when BOOST_THREAD_VERSION >= 3. As the default version has not been changed to version 3 in 1.53 as planned BOOST_THREAD_USES_MOVE is still not defined. I'm all for defining BOOST_THREAD_USES_MOVE even for version 2, but this will changes the interface. Comments of those that were against moving to version 3. Best, Vicente

On Wed, Jan 16, 2013 at 11:14 PM, Vicente J. Botet Escriba < vicente.botet@wanadoo.fr> wrote:
Le 17/01/13 03:34, Jeffrey Lee Hellrung, Jr. a écrit :
On Wed, Jan 16, 2013 at 10:06 AM, Vicente J. Botet Escriba < vicente.botet@wanadoo.fr> wrote:
Le 16/01/13 18:38, Jeffrey Lee Hellrung, Jr. a écrit :
On Wed, Jan 16, 2013 at 1:27 AM, Igor R <boost.lists@gmail.com> wrote:
I forgot to mention, but the above code compiles under MSVC10 and iOS gcc toolchain...
...which have rvalue references?
Yes, you're right, it turns out that while the above compilers have c++11 enabled by default, in ndk gcc4.7 it's disabled by default...
One suggestion: lobby for Boost.Thread to adopt Boost.Move rather than its own internal move emulation machinery (or, better yet, supply a patch!), and additionally use the Boost.Container data structures, which are Boost.Move-aware AFAIK.
Boost.Thread make use of Boost.Move when BOOST_THREAD_USES_MOVE is defined and can be used with Boost.Container or any standard c++ container. The problem is that it doesn't provides both emulations at once.
Remind me what the limitation of Boost.Move's emulation are wrt Boost.Thread, and how Boost.Thread's internal emulation avoids that limitation?
You misunderstood my concern. Boost.Move has no specific limitations with respect to Boost.Thread. Boost.Thread internal(old) emulation has more troubles than the one provided by Boost.Move.
I forgot to tell that BOOST_THREAD_USES_MOVE is defined by default when BOOST_THREAD_VERSION >= 3. As the default version has not been changed to version 3 in 1.53 as planned BOOST_THREAD_USES_MOVE is still not defined. I'm all for defining BOOST_THREAD_USES_MOVE even for version 2, but this will changes the interface.
Comments of those that were against moving to version 3.
Right, got it. Thanks for elaborating. - Jeff
participants (3)
-
Igor R
-
Jeffrey Lee Hellrung, Jr.
-
Vicente J. Botet Escriba