std::future_errc(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::future_errc πŸ’–

okay so bestie, this is the std::future_errc(3) page from the C++ Standard Libary manual β€” yes, the header spells it like that, and we’re not fixing it, we’re just vibing 🫢. It’s giving β€œtiny enum, big error-code energy,” and I’m obsessed.


🌸 NAME 🌸

std::future_errc β€” std::future_errc (the name is literally the name, bestie πŸ’…).


✨ Synopsis ✨

Defined in header <future>

enum class future_errc {

    broken_promise             = /* implementation-defined */,
    future_already_retrieved   = /* implementation-defined */,
(since C++11)
    promise_already_satisfied  = /* implementation-defined */,
    no_state                   = /* implementation-defined */

};

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. No cap, every single one is doing its own thing and none of them are zero β€” zero is not invited to this party πŸ’€.


πŸŽ€ Member constants πŸŽ€

  • broken_promise β€” the asynchronous task abandoned its shared state.
  • future_already_retrieved β€” the contents of shared state were already accessed through std::future.
  • promise_already_satisfied β€” attempt to store a value in the shared state twice.
  • no_state β€” attempt to access std::promise or std::future without an associated shared state.

πŸ’… Non-member functions πŸ’…

  • make_error_code(std::future_errc) β€” constructs a future error code; (C++11); function.
  • make_error_condition(std::future_errc) β€” constructs a future error_condition; (C++11); function.

🌈 Helper classes 🌈

  • is_error_code_enum<std::future_errc> β€” extends the type trait std::is_error_code_enum to identify future error codes; (C++11); class template.

πŸ“ Example πŸ“

This section is incomplete

Reason: no example


πŸ’€ Defect reports πŸ’€

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

  • DR LWG 2056 β€” Applied to: C++11. Behavior as published: broken_promise was specified to be zero which is conventionally used to mean "no error". Correct behavior: specified to be non-zero.

πŸ¦‹ See also πŸ¦‹

  • error_code β€” holds a platform-dependent error code; (C++11); class.
  • error_condition β€” holds a portable error code; (C++11); class.

⭐ Category ⭐

  • Todo no example

source/version/date check: this one’s from http://cppreference.com, version 2024.06.10, and it’s the std::future_errc(3) page β€” bye bestie, go handle your error codes πŸ’…βœ¨

πŸ“¦ where this page comes from