I don't think this is a duplicate. I'd read the "duplicate" before I asked... and I've read it again since.
In Scott Meyers' Effective Modern C++, Eighth Release, Item 38, p261 Scott says:
Once created, the
std::packaged_task
pt
can be run on a thread. (It could be run via a call tostd::async
, too, but if you want to run a task usingstd::async
, there's little reason to create astd::packaged_task
, becausestd::async
does everythingstd::packaged_task
does before it schedules the task for execution.)
"little". Not "no".
Scott is very precise. It is part of his style to use words like "almost always" or "usually" and then come back later to explain why he left the wiggle room. In this case he didn't.
So... can anyone tell me when there would be a reason to create a std::packaged_task if you want to run it with a std::async?