Hi Vicente,
I have an issue with Boost.Thread contructor using move-only type arguments.
The "Thread Constructor with arguments" section of the documentation says
...
template
thread(F f,A1 a1,A2 a2,...);
Preconditions:
F and each An must by copyable or movable.
http://www.boost.org/doc/libs/1_53_0/doc/html/thread/thread_management.html#...
"An" could be copyable or movable, but the following example fails to
compile...
error: use of deleted function 'A::A(const A&)'
//Begin code ------------------------------------
#include
struct A
{
A() = default;
A( const A& other) = delete;
A& operator=( const A& other) = delete;
A( A&& other) = default;
A& operator=( A&& other) = default;
void run() {}
};
void f( A a )
{
a.run();
}
void exec_boost()
{
A a;
boost::thread t( f, std::move(a) );
t.join();
}
//End code --------------------------------------
I think we should modify ...
template
thread(F f,A1 a1,typename
disable_if,
dummy* >::type=0):
thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1)))
{
start_thread();
}
... by ...
template
thread(F&& f,A1&& a1,typename
disable_if,
dummy* >::type=0):
thread_info(make_thread_info(boost::bind(boost::type<void>(),f,boost::forward<A1>(a1))))
{
start_thread();
}
( In the all family of related ctors in "boost/thread/detail/thread.hpp" )
But, I don't know if boost::bind is forwarding its arguments
I think we should modify Boost.Bind to be similar to std::bind.
Is there any reason why Bind has not changed so far? Have you found any
limitations?
If Bind can not be changed, I think Boost.Thread should use some other tool
similar to Bind to make forwarding parameters.
GCC Libstdc++ use a Bind-lite tool for std::thread.
I can work on this if you want.
What do you think?
Environment:
Windows 7 64bits
MinGW - GCC 4.7.2
MSVC 2010
MSVC 2012
Boost 1.53.0
Non-Variadic template code branch
Regards,
Fernando Pelliccioni