std::future_error::code

const std::error_code& code() const; (since C++11) Returns the stored error code. Parameters (none). Return value The stored error code. Exceptions noexcept specification: noexcept See also what returns the explanatory string specific to the error code (public member function)

std::future_errc

Defined in header <future> enum class future_errc { broken_promise = /* implementation-defined */, future_already_retrieved = /* implementation-defined */, promise_already_satisfied = /* implementation-defined */, no_state = /* implementation-defined */ }; (since C++11) The scoped enumeration std::future_errc defines the error codes reported by std::future and related classes in std::future_error exception objects. Only four

std::future::wait_for

template< class Rep, class Period > std::future_status wait_for( const std::chrono::duration<Rep,Period>& timeout_duration ) const; (since C++11) Waits for the result to become available. Blocks until specified timeout_duration has elapsed or the result becomes available, whichever comes first. Returns value identifies the state of the result. A steady clock is used to measure the duration. This function may block for longer than timeout_duration due to scheduling or res

std::future::wait_until

template< class Clock, class Duration > std::future_status wait_until( const std::chrono::time_point<Clock,Duration>& timeout_time ) const; (since C++11) wait_until waits for a result to become available. It blocks until specified timeout_time has been reached or the result becomes available, whichever comes first. The return value indicates why wait_until returned. The behavior is undefined if valid()== false before the call to this function. Parameters timeout_time

std::future::wait

void wait() const; (since C++11) Blocks until the result becomes available. valid() == true after the call. The behavior is undefined if valid()== false before the call to this function. Parameters (none). Return value (none). Exceptions (none). Notes The implementations are encouraged to detect the case when valid == false before the call and throw a std::future_error with an error condition of std::future_errc::no_state. Example #include <iostream> #include <

std::future_category

Defined in header <future> const std::error_category& future_category(); (since C++11) Obtains a reference to the static error category object for the errors related to futures and promises. The object is required to override the virtual function error_category::name() to return a pointer to the string "future". It is used to identify error codes provided in the exceptions of type std::future_error. Parameters (none). Return value A reference to the static object

std::future::future

future(); (1) (since C++11) future( future&& other ); (2) (since C++11) future( const future& other ) = delete; (3) (since C++11) Constructs a std::future object. 1) Default constructor. Constructs a std::future with no shared state. After construction, valid() == false. 2) Move constructor. Constructs a std::future with the shared state of other using move semantics. After construction, other.valid() == false. 3) std::future is not CopyConstructible. Parame

std::future

Defined in header <future> template< class T > class future; (1) (since C++11) template< class T > class future<T&>; (2) (since C++11) template<> class future<void>; (3) (since C++11) The class template std::future provides a mechanism to access the result of asynchronous operations: An asynchronous operation (created via std::async, std::packaged_task, or std::promise) can provide a std::future object to the creator o

std::future::valid

bool valid() const; (since C++11) Checks if the future refers to a shared state. This is the case only for futures that were not default-constructed or moved from (i.e. returned by std::promise::get_future(), std::packaged_task::get_future() or std::async()) until the first time get() or share() is called. The behavior is undefined if any member function other than the destructor, the move-assignment operator, or valid is called on a future that does not refer to shared state (although

std::future::get

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 ea