std::operat...error_code)(3)

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

πŸ’– std::operator==,!=,(std::error_code)(3) πŸ’–

okay so bestie, this is from the C++ Standard Libary manual (yes, that spelling is in the header πŸ’€), and it's all about comparing std::error_code objects. It's giving operator-overload realness, and every single overload here is noexcept. No cap. ✨

✨ Synopsis ✨

Defined in header <system_error>, bestie. Here's the synopsis, preserved exactly so nothing gets lost:

Defined in header <system_error>
bool operator==( const std::error_code& lhs,
(1) (since C++11)
                     const std::error_code& rhs ) noexcept;
bool operator!=( const std::error_code& lhs,
(2) (since C++11)
                     const std::error_code& rhs ) noexcept;
(until C++20)
bool operator<( const std::error_code& lhs,
(3) (since C++11)
                    const std::error_code& rhs ) noexcept;
(until C++20)
std::strong_ordering operator<=>( const std::error_code& lhs,
                                  const std::error_code& rhs )
(4) (since C++20)
noexcept;

The big picture: it compares two error code objects. 🫢

  • (1) (since C++11) β€” Compares lhs and rhs for equality.
  • (2) (since C++11), (until C++20) β€” Compares lhs and rhs for equality.
  • (3) (since C++11), (until C++20) β€” Checks whether lhs is less than rhs.
  • (4) (since C++20) β€” Obtains the three-way comparison result of lhs and rhs.

Also: the <, <=, >, >=, and != operators are synthesized from operator<=> (since C++20) and operator== respectively. periodt. πŸ’…

πŸŽ€ Parameters πŸŽ€

  • lhs, rhs β€” error codes to compare.

Two error codes walk into a comparison operator. That's the whole parameter list, bestie. πŸŽ€

πŸ”₯ Return value πŸ”₯

  • (1) true if the error category and error value compare equal.
  • (2) true if the error category or error value compare are not equal.
  • (3) true if lhs.category() < rhs.category(). Otherwise, true if lhs.category() == rhs.category() && lhs.value() < rhs.value(). Otherwise, false.
  • (4) lhs.category() <=> rhs.category() if it is not std::strong_ordering::equal. Otherwise, lhs.value() <=> rhs.value().

That's the whole return-value vibe check. πŸ”₯

🌈 See also 🌈

  • category β€” obtains the error_category for this error_code (public member function).
  • value β€” obtains the value of the error_code (public member function).
  • operator==
  • operator!=
  • operator< β€” compares error_conditions and error_codes.
  • operator<=> β€” (function).
  • (removed in C++20)
  • (removed in C++20)
  • (C++20)

That's the whole page, bestie πŸ’– Big cute sign-off: source/version is http://cppreference.com, and the date on this one is 2024.06.10. 🫢✨

πŸ“¦ where this page comes from