std::io_errc
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Input/output library
Print functions (C++23)
Buffers
(C++23)
(C++98/26*)
(C++20)
Streams
Abstractions
File I/O
String I/O
Array I/O
(C++23)
(C++23)
(C++23)
(C++98/26*)
(C++98/26*)
(C++98/26*)
Synchronized Output
(C++20)
Types
Error category interface
(C++11)
io_errc
(C++11)
std::io_errc
Non-member functions
(C++11)
Helper classes
(C++11)
Defined in header
<ios>
enum class io_errc {
(since C++11)
stream = 1,
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 .
[edit] Member constants
Enumeration constant
Value
stream
1
[edit] Non-member functions
[edit] Helper classes
(C++11)
(class template specialization) [edit]
[edit] Example
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