Topic: N3558: make_ready_future
Author: kosta-chrome@ks-baumann.de
Date: Mon, 25 Mar 2013 13:22:00 -0700 (PDT)
Raw View
Can make_ready_future() be extended to also take care for setting an exception in an easy way, e.g.:
template<typename RETURN>
std::future<RETURN> make_ready_future(std::exception_ptr ex) { ... }
or
template<typename RETURN, typename CLOSURE>
std::future<RETURN> make_reday_future(CLOSURE closure) {
std::promise<RETURN> p = ...;
std::future<RETURN> f = ...;
try { p.set_value(closure()); }
catch(...) { p.set_exception(std::current_exception()); }
return f;
}
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Mon, 25 Mar 2013 17:04:00 -0400
Raw View
On Mon, Mar 25, 2013 at 4:22 PM, <kosta-chrome@ks-baumann.de> wrote:
> Can make_ready_future() be extended to also take care for setting an exception in an easy way, e.g.:
>
> template<typename RETURN>
> std::future<RETURN> make_ready_future(std::exception_ptr ex) { ... }
>
> or
>
> template<typename RETURN, typename CLOSURE>
> std::future<RETURN> make_reday_future(CLOSURE closure) {
> std::promise<RETURN> p = ...;
> std::future<RETURN> f = ...;
> try { p.set_value(closure()); }
> catch(...) { p.set_exception(std::current_exception()); }
> return f;
> }
>
> --
You need to be careful - what if the RETURN type is
std::exception_ptr? Or RETURN type == CLOSURE type.
You probably need different function names or something to
disambiguate from the 'normal' make_ready_future.
make_exceptional_future()? Who wouldn't want an exceptional future?
Tony
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
.