std::io_errc(3)
๐ NAME ๐
okay bestie, welcome to std::io_errc โ yes, the std::io_errc(3) page from the C++ Standard Libary manual ๐
std::io_errc โ literally std::io_errc. That's the name, no cap ๐
โจ Synopsis โจ
It lives in header <ios>:
enum class io_errc {
stream = 1, (since C++11)
};
The scoped enumeration std::io_errc defines the error codes reported by I/O streams in std::ios_base::failure exception objects. Only one error code (std::io_errc::stream) is required, although the implementation may define additional error codes. Because the appropriate specialization of std::is_error_code_enum is provided, values of type std::io_errc are implicitly convertible to std::error_code ๐ฆ
lowkey important: only std::io_errc::stream is guaranteed, but implementations are allowed to add extra codes. iykyk ๐
๐งฎ Member constants ๐งฎ
- Enumeration constant:
stream - Value:
1
that's the whole lil' constants vibe, bestie โจ
๐ ๏ธ Non-member functions ๐ ๏ธ
make_error_code(std::io_errc)โ constructs an iostream error code (function) (C++11) ๐ซถmake_error_condition(std::io_errc)โ constructs an iostream error condition (function) (C++11) ๐
๐งธ Helper classes ๐งธ
is_error_code_enum<std::io_errc>โ extends the type traitstd::is_error_code_enumto identify iostream error codes (class template specialization) (C++11) ๐ธ
๐ Example ๐
run this code, bestie:
// Run this code
#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";
if (e.code() == std::io_errc::stream)
std::cout << "The error code is std::io_errc::stream\n";
}
}
๐ Output ๐
Caught an ios_base::failure.
The error code is std::io_errc::stream
ate, no crumbs ๐
๐ See also ๐
error_codeโ holds a platform-dependent error code (C++11) (class) ๐ฅerror_conditionโ holds a portable error code (C++11) (class) โญfailureโ stream exception (public member class ofstd::ios_base) ๐
mwah ๐ โ source: http://cppreference.com, date/version: 2024.06.10, for std::io_errc(3) in the C++ Standard Libary. periodt. ๐
๐ฆ 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