I'm using boost 1.51 on multiple platforms and compilers without C++11.
In my main thread I have a very long, expensive to copy, std::string
veryLongString
, that I need to pass to a new thread for processing.
After the new thread is created I have no more use for veryLongString
on the main thread so I'd like to move it into the boost::thread
ctor.
The main thread, or the scope of veryLongString
may end before the new thread completes, so passing by reference (e.g. with boost::ref
) is not an option.
Obviously, if veryLongString
was created as a shared_ptr<std::string>
then I could just copy the shared_ptr
into the thread ctor, but it wasn't, so I'd need to copy it anyway.
How can I [boost::]move()
veryLongString
into the boost::thread
ctor (probably using via boost::bind
)?
Is this possible?