This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Promise, future and thread on C++0x


On 7 July 2011 10:47, Jonathan Wakely wrote:
> On 7 July 2011 10:29, Claudio La Rosa wrote:
>>
>> Ok, but there is no simple way to work around the problem?
>
> Pass the promise by lvalue reference:
>
> void myAsyncFun(promise<int>& intPromise)
> { ... }

That works in GCC 4.6, but not in 4.5 due to a different bug in
std::thread which is fixed in GCC 4.6

You can make it work in 4.5 by passing the promise to the thread by
reference instead of moving it:

std::thread t(myAsyncFun, std::ref(intPromise));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]