diff --git a/include/future b/include/future index ff8e59b1..7561d190 100644 --- a/include/future +++ b/include/future @@ -2331,20 +2331,32 @@ private: } }; +bool __does_policy_contain(launch __policy, launch __value ) +{ return (int(__policy) & int(__value)) != 0; } + template future::type, typename decay<_Args>::type...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func::type, typename decay<_Args>::type...> _BF; typedef typename _BF::_Rp _Rp; - future<_Rp> __r; - if (int(__policy) & int(launch::async)) - __r = _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), + +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif + if (__does_policy_contain(__policy, launch::async)) + return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - else if (int(__policy) & int(launch::deferred)) - __r = _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch ( ... ) { if (__policy == launch::async) throw ; } +#endif + + if (__does_policy_contain(__policy, launch::deferred)) + return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - return __r; + return future<_Rp>{}; } template diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html index 87e65f74..15515fd5 100644 --- a/www/cxx1y_status.html +++ b/www/cxx1y_status.html @@ -196,7 +196,7 @@ 2194Impossible container requirements for adaptor typesChicagoComplete 2013Do library implementers have the freedom to add constexpr?ChicagoComplete 2018regex_traits::isctype Returns clause is wrongChicagoComplete - 2078Throw specification of async() incompleteChicago + 2078Throw specification of async() incompleteChicagoComplete 2097packaged_task constructors should be constrainedChicagoComplete 2100Timed waiting functions cannot timeout if launch::async policy usedChicagoComplete 2120What should async do if neither 'async' nor 'deferred' is set in policy?ChicagoComplete