std::generic_category(3)

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

πŸ’– NAME πŸ’–

Okay so the NAME is literally std::generic_category - std::generic_category β€” yes bestie, the page is named after the function, main character energy fr fr. This is the std::generic_category(3) page from the C++ Standard Libary manual, and we're about to make it make sense. 🫢


πŸ“š Synopsis πŸ“š

Defined in header <system_error>.

const std::error_category& generic_category() noexcept;

(since C++11) β€” noted, bestie. ✨

Okay so what does it do? It obtains a reference to the static error category object for generic errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "generic". It is used to identify error conditions that correspond to the POSIX errno codes. That's the whole lore. πŸ’…


πŸŽ€ Parameters πŸŽ€

(none) β€” literally none, not a single parameter. The vibe check is empty and we love that. 🫢


πŸ¦‹ Return value πŸ¦‹

A reference to the static object of unspecified runtime type, derived from std::error_category. No cap, that's the return value. πŸ’œ


✨ Example ✨

       // Run this code

        #include <cerrno>
        #include <iostream>
        #include <string>
        #include <system_error>

        int main()
        {
            std::error_condition econd =
       std::generic_category().default_error_condition(EDOM);
            std::cout << "Category: " << econd.category().name() << '\n'
                      << "Value: " << econd.value() << '\n'
                      << "Message: " << econd.message() << '\n';
        }

🌈 Output: 🌈

Category: generic
Value: 33
Message: Numerical argument out of domain

Not me getting emotional over a category name and a number. πŸ˜­πŸ’–


πŸ‘‘ See also πŸ‘‘

  • system_category β€” identifies the operating system error category (C++11) (function)
  • errc β€” the std::error_condition enumeration listing all standard <cerrno> macro constants (C++11) (class)

mwah πŸ’‹ β€” source/version: http://cppreference.com, date: 2024.06.10, page: std::generic_category(3). Bye bestie! πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from