std::iostream_category(3)
β¨ std::iostream_category(3) β¨
okay so this little page is from the C++ Standard Libary corner of cppreference, and we are about to make std::iostream_category make sense. it's giving βniche but iconicβ energy, and honestly? obsessed. π
π NAME π
std::iostream_category - std::iostream_category
yes bestie, the name repeats, and we are simply going to let it have that main character moment. π
π¦ Synopsis π¦
Defined in header <ios>:
const std::error_category& iostream_category() noexcept; (since C++11)
So what does it do? It obtains a reference to the static error category object for iostream errors. That object is required to override the virtual function error_category::name() to return a pointer to the string "iostream". It is used to identify error codes provided in the exceptions of type std::ios_base::failure. no cap, that's the whole vibe check. β¨
πΈ Parameters πΈ
None. Nada. Zero. This one takes no arguments, bestie. π«Ά
π§ Return value π§
A reference to the static object of unspecified runtime type, derived from std::error_category. literally that's it, and it ate. π
π₯ Example π₯
#include <fstream>
#include <iostream>
int main()
{
std::ifstream f("doesn't exist");
try
{
f.exceptions(f.failbit);
}
catch (const std::ios_base::failure& e)
{
std::cout << "Caught an ios_base::failure.\n"
<< "Error code: " << e.code().value()
<< " (" << e.code().message() << ")\n"
<< "Error category: " << e.code().category().name()
<< '\n';
}
}
π Possible output: π
Caught an ios_base::failure.
Error code: 1 (unspecified iostream_category error)
Error category: iostream
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards:
- DR:
LWG 2087β Applied to: C++11- Behavior as published:
iostream_categorywas not declarednoexcept - Correct behavior: declared
noexcept
- Behavior as published:
periodt. the standards said βbestie, fix the noexcept,β and they did. π«‘
π See also π
failureβ stream exception (public member class ofstd::ios_base)io_errcβ the IO stream error codes (C++11) (enum)
π«Ά that's the whole page, bestie! source/version/date vibes:http://cppreference.com,2024.06.10, and the page tagstd::iostream_category(3)β mwah π
π¦ 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