Boost logo

Boost :

Subject: Re: [boost] [Thread] Non-copyable boost::thread
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2010-05-17 04:25:27


"Belcourt, Kenneth" <kbelco_at_[hidden]> writes:

> Intel-11.1 on Darwin is a recent compiler that will not compile this
> code.
>
>
> [ from libs/thread/test/test_thread_return_local.cpp ]
>
> boost::thread make_thread_return_local(boost::thread::id* the_id)
> {
> boost::thread t(do_nothing,the_id);
> return t;
> }
>
>
> The same error message is generated in both debug and release builds
> on Darwin (though strangely it doesn't appear to be an error with
> Intel 11.1 on Linux).
>
> ../libs/thread/test/test_thread_return_local.cpp(16): error #373:
> "boost::thread::thread(boost::thread &)" (declared at line 111 of "../
> boost/thread/detail/thread.hpp") is inaccessible
> return t;
> ^
>
> Any ideas how to work around this failure?

Explicitly move the return value:

return std::move(t);

or even

return std::thread(std::move(t));

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk