The paper that you linked (N3722) explicitly says that only std::future<T>
and std::shared_future<T>
are accepted as a return type for a resumable
function:
The return type of a resumable function must be future or shared_future . The restrictions on T are defined by std::future, not this proposal, but T must be a copyable or movable type, or ‘void.’ It must also be possible to construct a variable of T without an argument; that is, it has to have an accessible (implicit or explic it) default constructor if it is of a class type.
However, the section 4 of the proposal (Generalization
) proposes to lift the return type restriction. The returned type should be any type with the following restrictions:
The operand of the unary operator
await
can be any typeS<<T>>
(“S eventually holding a T”) with meets the following conditions:
- S has a parameter-less function
get
which will either eventually produce a value of type T, or throw an exception.- S has a function
then
accepting a single-parameter function object taking a parameterS<<T>>
,S<<T>>&
, orconst S<<T>>
. Once passed tothen
, the value held by the parameter must be immediately available for retrieval by a call toget
.- Optionally, if
S<<T>>
has abool
-returning functionis_ready()
indicating whether a value is already held, the implementation ofawait
can be made more efficient.
Currently, the discussion is still open. It the generalization is accepted, a resumable
function will be able to return a boost::future
. Otherwise, it will be limited to std::future
and std::shared_future
.