
----- Original Message ----- From: "Anthony Williams" <anthony.ajw@gmail.com> To: <boost@lists.boost.org> Sent: Wednesday, February 11, 2009 9:31 AM Subject: Re: [boost] Futures Review - Shouldpackaged_taskbeCopyConstructible?
"vicente.botet" <vicente.botet@wanadoo.fr> writes:
Sorry i was not clear. The problem is that the reference to the task
std::packaged_task<result_type> task(std::move(f));
has been stored in the set_wait_callback. But this address is no more valable when the function returns, so when the user gets the future and call to get, the callback uses a bad address. Hoping it is clear now.
Yes, it's clear. That's a design issue with set_wait_callback.
Ok, I see. Anyway, I think that examples like template<typename F> std::packaged_task<typename std::result_of<F()>::type> lazy_call(F f);
should be included in the library, at least as an example.
That's a good idea.
Have you an idea how to solve the design issue to implement lazy_call? In http://www.nabble.com/Futures-Review-Starts-Today---January-5%2C-2009-tt2130..., I requested the differences between a lazy future and a function pointer. Please could you answer to this post? Best, Vicente