std::error_...erator==,!=,(3)

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

πŸ’– std::error_...erator==,!=,(3) πŸ’–

okay so real talk, bestie: this page is from the <cyan>C++ Standard Libary</cyan> manual β€” yes, spelled exactly like that in the manual name, β€œLibary” and all, I’m not fixing it β€” and it’s the whole group-chat saga of comparing std::error_category objects. πŸ’…


🌸 NAME 🌸

std::error_category::operator==,!=, β€” std::error_category::operator==,!=,

(yes, the description is literally the same truncated string, iconic behavior, no notes πŸ’€)


✨ Synopsis ✨

the overload lineup, with all the version labels kept exactly as they are:

  • (1) (since C++11) β€” bool operator==( const error_category& rhs ) const noexcept;
  • (2) (since C++11) (until C++20) β€” bool operator!=( const error_category& rhs ) const noexcept;
  • (3) (since C++11) (until C++20) β€” bool operator<( const error_category& rhs ) const noexcept;
  • (4) (since C++20) β€” std::strong_ordering operator<=>( const error_category& rhs ) const noexcept;

Compares to another error category. that’s the whole main character job. here’s the breakdown:

  1. Checks whether *this and rhs refer to the same object. πŸ’–
  2. Checks whether *this and rhs do not refer to the same object. πŸ™ˆ
  3. Orders *this and rhs by the order of this and &rhs. Equivalent to std::less<const error_category*>()(this, &rhs). πŸ”₯
  4. Orders *this and rhs by the order of this and &rhs. Equivalent to std::compare_three_way()(this, &rhs). ⭐

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


πŸŽ€ Parameters πŸŽ€

  • rhs β€” specifies the error_category to compare. πŸ’–

πŸ“ Return value πŸ“

  1. true if *this and rhs refer to the same object, false otherwise.
  2. true if *this and rhs do not refer to the same object, false otherwise.
  3. true if *this is less than rhs as defined by the order of this and &rhs.
  4. std::strong_order::less if *this is less than rhs as defined by the order of this and &rhs, otherwise std::strong_order::greater if rhs is less than *this in the order, otherwise std::strong_order::equal.

xoxo, your Unix bestie πŸ’… β€” source/version: http://cppreference.com, 2024.06.10, page: std::error_...erator==,!=,(3). 🫢✨

πŸ“¦ where this page comes from