Namespaces
Variants
Actions

std::future_errc

From cppreference.com
< cpp‎ | thread
 
 
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
(C++11)
(C++11)
(C++11)
(C++11)
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
(C++11)
future_errc
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
Memory ordering
(C++11)(deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
 
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 error codes are required, although the implementation may define additional error codes. Because the appropriate specialization of std::is_error_code_enum is provided, values of type std::future_errc are implicitly convertible to std::error_code.

All error codes are distinct and non-zero.

Contents

[edit] Member constants

EnumeratorMeaning
broken_promisethe asynchronous task abandoned its shared state
future_already_retrievedthe contents of shared state were already accessed through std::future
promise_already_satisfiedattempt to store a value in the shared state twice
no_stateattempt to access std::promise or std::future without an associated shared state

[edit] Non-member functions

constructs a future error code
(function) [edit]
constructs a future error_condition
(function) [edit]

[edit] Helper classes

extends the type trait std::is_error_code_enum to identify future error codes
(class template) [edit]

[edit] Example

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DRApplied toBehavior as publishedCorrect behavior
LWG 2056C++11broken_promise was specified to be zero which is conventionally used to mean “no error”specified to be non-zero

[edit] See also

(C++11)
holds a platform-dependent error code
(class) [edit]
holds a portable error code
(class) [edit]