std::system_category(3)
okay bestie, buckle up: this is std::system_category(3) from the C++ Standard Libary (yes, that's the manual name, and yes, we're keeping it exactly like that π
).
π NAME π
std::system_categoryβ thestd::system_categoryfunction, no cap. That's the whole name, and we're moving on. π¦
β¨ Synopsis β¨
Defined in header <system_error>.
const std::error_category& system_category() noexcept;
(since C++11) β she's been iconic since then, periodt.
Okay so this obtains a reference to the static error category object for errors reported by the operating system. The object is required to override the virtual function std::error_category::name() to return a pointer to the string "system". It is also required to override the virtual function std::error_category::default_error_condition() to map the error codes that match POSIX errno values to std::generic_category.
π Parameters π
(none) β literally none, bestie. Not a single parameter. π
π Return value π
A reference to the static object of unspecified runtime type, derived from std::error_category.
π¦ Notes π¦
On Windows, system_category() typically maps some Windows error codes to POSIX ones. On POSIX, system_category() tends to be equivalent to std::generic_category() except for the name.
πΈ Example πΈ
// Run this code
#include <iomanip>
#include <iostream>
#include <string>
#include <system_error>
int main()
{
for (int const code : {EDOM, 10001})
{
const std::error_condition econd =
std::system_category().default_error_condition(code);
std::cout << "Category: " << econd.category().name() << '\n'
<< "Value: " << econd.value() << '\n'
<< "Message: " << econd.message() << "\n\n";
}
}
Possible output:
Category: generic
Value: 33
Message: Numerical argument out of domain
Category: system
Value: 10001
Message: Unknown error 10001
π See also π
generic_categoryβ identifies the generic error category. (function,(C++11))errcβ thestd::error_conditionenumeration listing all standard<cerrno>macro constants. (class,(C++11))
and that's the whole page, bestie π«Ά source/version/date vibes: http://cppreference.com, 2024.06.10, and the title is std::system_category(3). byeee π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms