enum class launch { any, async, sync };
template<class F, class ...Args>
unique_future<typename F::result_type>
async( F&& f, Args&&... args );
template<class F, class ...Args>
unique_future<typename F::result_type>
async( launch policy, F&& f, Args&&... args );
and I'm wondering why "typename F::result_type" is used instead of
"typename result_of<F(Args...)>::type" or "typename result_of<F&
(Args...)>::type". It seems we have to wrap function pointers into a
class-type object just to be able to use them for std::async. Is this
intentional or an oversight?
Cheers,
SG
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std...@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
This is an oversight, the correct one is typename result_of<F(Args...)
>::type.
Greetings from Bremen,
- Daniel Kr�gler
> N2996 declares std::async as:
>
> enum class launch { any, async, sync };
>
> template<class F, class ...Args>
> unique_future<typename F::result_type>
> async( F&& f, Args&&... args );
>
> template<class F, class ...Args>
> unique_future<typename F::result_type>
> async( launch policy, F&& f, Args&&... args );
>
> and I'm wondering why "typename F::result_type" is used instead of
> "typename result_of<F(Args...)>::type" or "typename result_of<F&
> (Args...)>::type". It seems we have to wrap function pointers into a
> class-type object just to be able to use them for std::async. Is this
> intentional or an oversight?
It's an oversight. It was spotted too late for the latest WP draft.
Anthony
--
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x thread library | http://www.stdthread.co.uk
Just Software Solutions Ltd | http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976