On Mon, Apr 9, 2012 at 4:54 PM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
Le 10/04/12 01:24, Jeffrey Lee Hellrung, Jr. a écrit :The overload
explicit packaged_task(R(*f)()):
task(new detail::task_object<R,R(*)()>(f)),future_obtained(false)
{}
seems necessary because otherwise the task_object is instantiated with <R,R()> which is not what we want.
Do you have an hint on how simplify this?
Okay yeah I wasn't sure why you needed this overload, thanks for clarifying. I guess when constructing a packaged_task with a function name, and you don't explicitly use the address-of operator (&), F gets bound as a function reference? Probably easiest to just explicitly use a separate constructor as above and document its necessity.
Please, could you check the patch and see if there is something that can be improved.
The test futures/packaged_task/alloc_ctor_pass.cpp gives this context.
Thanks for your patience and perseverance.
And thank you for clarifying the issue for me!
Yeah that looks about what I would've suggested. Just add, like you said, the remove_cv's.