Namespaces
Variants

std::experimental:: make_exceptional_future

From cppreference.net
定义于头文件 <experimental/future>
template < class T >
future < T > make_exceptional_future ( std:: exception_ptr ex ) ;
(1) (并发TS)
template < class T, class E >
future < T > make_exceptional_future ( E ex ) ;
(2) (并发TS)
1) 创建一个类型为 T 的共享状态,该状态立即可用并存储异常指针 ex ,然后返回与该共享状态关联的 future,如同通过 promise < T > p ; p. set_exception ( ex ) ; return p. get_future ( ) ; 实现。如果 ex 为空则行为未定义。
2) 创建一个类型为 T 的共享状态,该状态立即可用并存储由 ex 创建的异常指针,然后返回与该共享状态关联的 future,如同通过 promise < T > p ; p. set_exception ( std:: make_exception_ptr ( ex ) ) ; return p. get_future ( ) ; 实现。

返回值

一个与已创建的共享状态相关联的 future 对象。

另请参阅

(concurrency TS)
生成一个立即就绪并持有给定值的 future
(函数模板)