std::error_...::error_code(3)

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

πŸ’– std::error_...::error_code(3) πŸ’–

okay bestie, welcome to std::error_...::error_code(3) from the C++ Standard Libary manual β€” that's the exact manual spelling, no cap, we are not correcting it πŸ’…. This page is all about the std::error_code constructors, and it's lowkey giving "small object, big feelings."


🌸 NAME 🌸

std::error_code::error_code - std::error_code::error_code

✨ SYNOPSIS ✨

error_code() noexcept;                                     (1) (since C++11)
error_code( int ec, const error_category& ecat ) noexcept; (2) (since C++11)
template< class ErrorCodeEnum >                            (3) (since C++11)
error_code( ErrorCodeEnum e ) noexcept;
error_code( const error_code& other ) = default;           (4) (since C++11)
                                                           (implicitly declared)
error_code( error_code&& other ) = default;                (5) (since C++11)
                                                           (implicitly declared)

Constructs new error code. Not me getting emotional over a constructor 😭. Here's the tea, overload by overload:

  1. (1) β€” Constructs error code with default value. Equivalent to error_code(0, std::system_category()).
  2. (2) β€” Constructs error code with ec as the platform-dependent error code and ecat as the corresponding error category.
  3. (3) β€” Constructs error code from an error code enum e. Equivalent to make_error_code(e), where make_error_code is only found by argument-dependent lookup. This overload participates in overload resolution only if std::is_error_code_enum<ErrorCodeEnum>::value is true.
🚨 overload-resolution vibe check: number (3) is only in the club if std::is_error_code_enum<ErrorCodeEnum>::value is true. periodt.
  1. (4), (5) β€” Implicitly defined copy constructor and move constructor. Initializes the error code with the contents of the other.

πŸŽ€ PARAMETERS πŸŽ€

  • other β€” another error code to initialize with
  • ec β€” platform dependent error code to construct with
  • ecat β€” error category corresponding to ec
  • e β€” error code enum to construct with

πŸ’€ DEFECT REPORTS πŸ’€

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

  • DR LWG 3629, applied to C++11 β€” behavior as published: only std::make_error_code overloads were ADL-found; correct behavior: ADL-found overloads are used.

πŸ¦‹ SEE ALSO πŸ¦‹

  • make_error_code(std::errc) (C++11) β€” creates error code value for errc enum e; (function)
  • make_error_code(std::io_errc) (C++11) β€” constructs an iostream error code; (function)
  • make_error_code(std::future_errc) (C++11) β€” constructs a future error code; (function)

okay that's the whole page, bestie 🫢. source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::error_...::error_code(3). slay, go construct some error codes responsibly πŸ’–βœ¨.

πŸ“¦ where this page comes from