std::future<T>::get (3) - Linux Man Pages
T get(); (1) (member only of generic future template)
T& get(); (2) (member only of future<T&> template specialization)
void get(); (3) (member only of future<void> template specialization)
The get method waits until the future has a valid result and (depending on which template is used) retrieves it. It effectively calls wait() in order to wait for the result.
The generic template and two template specializations each contain a single version of get. The three versions of get differ only in the return type.
The behavior is undefined if valid() is false before the call to this function.
Any shared state is released. valid() is false after a call to this method.
1) The value v stored in the shared state, as std::move(v).
2) The reference stored as value in the shared state.
If an exception was stored in the shared state referenced by the future (e.g. via a call to std::promise::set_exception()) then that exception will be thrown.
The implementations are encouraged to detect the case when valid() is false before the call and throw a std::future_error with an error condition of std::future_errc::no_state.
// Run this code