Topic: std::async return type
Author: SG <s.gesemann@gmail.com>
Date: Sun, 15 Nov 2009 19:08:36 CST Raw View
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?
Cheers,
SG
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Mon, 16 Nov 2009 13:38:46 CST Raw View
On Nov 16, 2:08 am, SG <s.gesem...@gmail.com> wrote:
> 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?
This is an oversight, the correct one is typename result_of<F(Args...)
>::type.
Greetings from Bremen,
- Daniel Kr gler
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Anthony Williams <anthony.ajw@gmail.com>
Date: Mon, 16 Nov 2009 13:39:28 CST Raw View
SG <s.gesemann@gmail.com> writes:
> 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
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]