std::error_...or_condition(3)

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

πŸ’… std::error_condition::error_condition

okay bestie, welcome to the C++ Standard Library page for std::error_condition::error_condition β€” yes the constructor, yes it's named after its own class twice, that's just how this house does it πŸ’– (and yeah, the page header calls it std::error_...or_condition(3) because terminals are dramatic and truncate things, love that for us).


✨ SYNOPSIS ✨

error_condition() noexcept;                                (1) (since C++11)
error_condition( int val, const error_category& cat )      (2) (since C++11)
noexcept;
template< class ErrorConditionEnum >                       (3) (since C++11)
error_condition( ErrorConditionEnum e ) noexcept;
error_condition( const error_condition& other ) = default; (4) (since C++11)
                                                              (implicitly declared)
error_condition( error_condition&& other ) = default;      (5) (since C++11)
                                                              (implicitly declared)

Constructs a new error condition. iconic behaviour tbh πŸŽ€


🌸 DESCRIPTION 🌸

So here's what each overload is giving:

  1. Default constructor. Initializes the error condition with the generic category and error value 0. the "no thoughts, head empty" of error conditions 🫧
  2. Initializes the error condition with error value val and error category cat. you pick the numbers, you pick the vibes.
  3. Initializes the error condition with enum e. Effectively calls make_error_condition that is only found by argument-dependent lookup for e. This overload participates in overload resolution only if std::is_error_condition_enum<ErrorConditionEnum>::value is true. (very "iykyk", very ADL ✨)
  4. Implicitly defined copy constructor and move constructor (that's 4 and 5, together, besties). Initializes the error condition with the contents of other.

πŸ¦‹ PARAMETERS πŸ¦‹

  • other β€” another error condition to initialize with
  • val β€” error value
  • cat β€” error category
  • e β€” error condition enum

πŸ’€ DEFECT REPORTS πŸ’€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. (yes, they went back and fixed it, no cap, that's genuinely main character energy πŸ‘‘)

  • LWG 3629 β€” Applied to: C++11
    • Behavior as published: only std::make_error_condition overloads were used
    • Correct behavior: ADL-found overloads are used

🌈 SEE ALSO 🌈

  • make_error_condition(std::errc) (since C++11) β€” creates an error condition for an errc value (function)
  • make_error_condition(std::io_errc) (since C++11) β€” constructs an iostream error condition (function)
  • make_error_condition(std::future_errc) (since C++11) β€” constructs a future error_condition (function)

okay that's the whole page, you ate that πŸ“ no notes. this little masterpiece is from cppreference.com, dated 2024.06.10, and it lives at std::error_...or_condition(3) β€” go forth and construct your error conditions responsibly, mwah πŸ’œπŸ§š

πŸ“¦ where this page comes from