std::promise<R>::promise

< cpp‎ | thread‎ | promise
promise();
(1) (C++11 起)
template< class Alloc >
promise( std::allocator_arg_t, const Alloc& alloc );
(2) (C++11 起)
promise( promise&& other ) noexcept;
(3) (C++11 起)
promise( const promise& other ) = delete;
(4) (C++11 起)

构造 promise 对象。

1) 默认构造函数。构造具有空共享状态的承诺体;
2) 构造具有空共享状态的承诺体。由 alloc 分配共享状态。Alloc 必须满足分配器 (Allocator) 的要求;
3) 移动构造函数。使用移动语义从 other 的共享状态构造承诺体对象。构造完毕后,other 无共享状态;
4) promise 不可复制。

参数

alloc - 用于分配共享状态的分配器
other - 要从之获取状态的另一 promise 对象

异常

1,2) 可能会抛出由实现定义的异常。

示例