std::future::get

From cppreference.com

T get();
(1) (member only of generic future template)
(since C++11)
T& get();
(2) (member only of future<T&> template specialization)
(since C++11)
void get();
(3) (member only of future<void> template specialization)
(since C++11)

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.

valid()  == false after a call to this method.

Contents

[edit] Parameters

(none)

[edit] Return value

1) The value stored in the shared state. If it satisfies the requirements of MoveAssignable, the value is moved, otherwise it is copied.

2) Reference to the value in the shared state.

3) Nothing.

[edit] Exceptions

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.

[edit] Example

[edit] See also

checks if the future has a shared state
(public member function)