This constructor creates a new shared state that becomes satisfied when both rhs and rhs.get() become satisfied. If rhs is satisfied, but rhs.get() returns an invalid future then the newly created future becomes satisfied with a std::future_error exception, and the exception error code is std::future_errc::broken_promise.
Parameter
Name
Description
rhs
future< future< void > > &&
future(future< T > &&)
Creates a future from a future whose result type is convertible to this future's result type.
Parameters
Name
Description
rhs
future< T > &&
class T
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
void
then(F &&)
Attach a continuation to the future.
Attach a callable func to be invoked when the future is ready. The return type is a future wrapping the return type of func.
Side effects: valid() == false if 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 is std::result_of_t<F, R> (basically). If T matches future<U> then it returns future<U>. The returned future will contain the result of func.
Type Aliases
shared_state_type
Alias Of: typename internal::future_base< internal::FutureVoid >::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 2025-03-05 UTC."],[[["The latest version available is 2.37.0-rc, with numerous older versions available ranging down to 2.10.1."],["This documentation outlines the `future\u003cvoid\u003e` class, a specialization of `future` for void types that includes constructors for creating and unwrapping futures."],["Key functionalities of `future\u003cvoid\u003e` include `get()`, which waits for the shared state to be ready and retrieves its value, and `then(F &&)`, which attaches a continuation function to be invoked when the future is ready."],["There are detailed descriptions of the constructors, including one for unwrapping nested futures and another for creating futures from types convertible to this future's type, as well as descriptions of the parameters, exceptions, and return types associated with the functions."],["The type alias `shared_state_type` is described as being an alias of `typename internal::future_base\u003c internal::FutureVoid \u003e::shared_state_type`."]]],[]]