Boost logo

Boost Users :

Subject: Re: [Boost-users] Moving an std::string into a boost::thread in C++03
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2012-10-04 06:00:32


auto p = make_shared<string>();
p->swap( veryLongString );

And now you have a shared pointer with moved contents of veryLongString ;-)

Regards,
Kris

2012/10/4 Szymon Gatner <szymon.gatner_at_[hidden]>:
> 2012/10/4 Adi Shavit <adishavit_at_[hidden]>:
>> Hi,
>>
>>
>> How can I [boost::]move() veryLongString into the boost::thread ctor
>> (probably using via boost::bind)?
>> Is this possible?
>>
>
> Hi, Adi
>
> sorry, bind() can only do as much also - either doing a copy of a
> std::string or using a reference to it.
>
> As you mentioned, you have to use shared_ptr<> to pass ownership or
> use boost::container::string which is movable (even in 03 compilers
> via boost.move emulation) instead of std::string.
>
> Cheers,
> Szymon
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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