std::error_category(3cxx)

πŸ¦‹ std::error_category πŸ¦‹

okay bestie, welcome to the std::error_category(3cxx) manual page from libstdc++ β€” and it's giving "abstract base class for error codes" but make it make sense, yeah? πŸ’…


🌸 NAME 🌸

std::error_category β€” literally the name, no cap.

✨ SYNOPSIS ✨

#include <system_error>

πŸŽ€ Public Member Functions πŸŽ€

  • error_category (const error_category &)=delete β€” this one is =delete; the compiler said no copying, bestie.
  • virtual error_condition default_error_condition (int __i) const noexcept β€” return an error_condition corresponding to i in this category.
  • virtual bool equivalent (const error_code &__code, int __i) const noexcept β€” test whether code corresponds to i for this category.
  • virtual bool equivalent (int __i, const error_condition &__cond) const noexcept β€” test whether cond corresponds to i for this category.
  • virtual string message (int) const =0 β€” the =0 is right there, bestie.
  • virtual const char * name () const noexcept=0 β€” a string that identifies the error category.
  • strong_ordering operator<=> (const error_category &__rhs) const noexcept β€” ordered comparison that defines a total order for error categories.
  • error_category & operator= (const error_category &)=delete β€” assignment is also =delete; not here for the copy-paste era.
  • bool operator== (const error_category &__other) const noexcept β€” an error_category only compares equal to itself.

πŸ’– Detailed Description πŸ’–

okay so std::error_category is an abstract base class for types defining a category of error codes. It's the context machine that gives meaning to the integer stored in an error_code or error_condition object.

For example, the standard errno constants like EINVAL and ENOMEM are associated with the 'generic' category, and other OS-specific error numbers are associated with the 'system' category. But a user-defined category might give different meanings to the same numerical values. Same number, different lore β€” iykyk.

A user-defined category can override the equivalent member functions to define correspondence between errors in different categories. For example, a category for errors from disk I/O could consider some of its error numbers equivalent to ENOSPC and ENOENT in the generic category. That's the crossover episode energy, fr fr.

🌟 Since 🌟

C++11


πŸ’œ Member Function Documentation πŸ’œ

πŸ¦‹ virtual error_condition std::error_category::default_error_condition (int __i) const πŸ¦‹

[virtual], [noexcept]

Return an error_condition corresponding to i in this category.

πŸ’« virtual bool std::error_category::equivalent (const error_code & __code, int __i) const πŸ’«

[virtual], [noexcept]

Test whether code corresponds to i for this category.

🫢 virtual bool std::error_category::equivalent (int __i, const error_condition & __cond) const 🫢

[virtual], [noexcept]

Test whether cond corresponds to i for this category.

πŸŽ€ virtual const char * std::error_category::name () const πŸŽ€

[pure virtual], [noexcept]

A string that identifies the error category.

⭐ strong_ordering std::error_category::operator<=> (const error_category & __rhs) const ⭐

[inline], [noexcept]

Ordered comparison that defines a total order for error categories.

🌈 bool std::error_category::operator== (const error_category & __other) const 🌈

[inline], [noexcept]

An error_category only compares equal to itself.


🌸 Author 🌸

Generated automatically by Doxygen for libstdc++ from the source code. So you know who to thank for the autogenerated lore, bestie.


Footer vibe check: source/version shoutout goes to libstdc++, manual name is std::error_category(3cxx), and the footer date is literally not shown on this page β€” don't @ me. Bye bestie, slay your error categories πŸ’…βœ¨

πŸ“¦ where this page comes from