Class future<T> (3.4.0-rc)Stay organized with collectionsSave and categorize content based on your preferences.
Implement ISO/IEC TS 19571:2016future<T>.
Constructors
future()
future(future< future< T > > &&)
Creates a new future that unwrapsrhs.
This constructor creates a new shared state that becomes satisfied when bothrhsandrhs.get()become satisfied. Ifrhsis satisfied, butrhs.get()returns an invalid future then the newly created future becomes satisfied with astd::future_errorexception, and the exception error code isstd::future_errc::broken_promise.
Parameter
Name
Description
rhs
future< future< T > > &&
future(future< U > &&)
Creates a future from a future whose result type is convertible to this future's result type.
Parameters
Name
Description
rhs
future< U > &&
class U
typename Enable
future(std::shared_ptr< shared_state_type >)
Parameter
Name
Description
state
std::shared_ptr< shared_state_type >
Functions
get()
Waits until the shared state becomes ready, then retrieves the value stored in the shared state.
Exceptions
Type
Description
...
any exceptions stored in the shared state.
std::future_error
with std::no_state if the future does not have a shared state.
Returns
Type
Description
T
then(F &&)
Attach a continuation to the future.
Attach a callablefuncto be invoked when the future is ready. The return type is a future wrapping the return type offunc.
Side effects:valid() == falseif the operation is successful.
Parameters
Name
Description
func
F &&
a Callable to be invoked when the future is ready. The function might be called immediately, e.g., if the future is ready.
typename F
Returns
Type
Description
future< >
future<T>where T isstd::result_of_t<F, R>(basically). If T matchesfuture<U>then it returnsfuture<U>. The returned future will contain the result offunc.
Type Aliases
shared_state_type
Alias Of:typename internal::future_base< T >::shared_state_type
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-03-31 UTC."],[],[]]