Boost logo

Boost Users :

Subject: [Boost-users] Moving an std::string into a boost::thread in C++03
From: Adi Shavit (adishavit_at_[hidden])
Date: 2012-10-04 05:11:37


Hi,

  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,
hence I'd like to *move *it into the boost::thread ctor.

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?

Thanks,
Adi



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net