| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| 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) |
| Non-member functions | ||||
| Helper classes | ||||
Defined in header <ios> | ||
enumclass io_errc{ stream=1, | (since C++11) | |
The scoped enumerationstd::io_errc defines the error codes reported by I/O streams instd::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 ofstd::is_error_code_enum is provided, values of typestd::io_errc are implicitly convertible tostd::error_code.
Contents |
| Enumeration constant | Value |
stream | 1 |
| constructs an iostream error code (function)[edit] | |
| constructs an iostream error condition (function)[edit] |
| extends the type traitstd::is_error_code_enum to identify iostream error codes (class template specialization)[edit] |
#include <fstream>#include <iostream> int main(){std::ifstream f("doesn't exist");try{ f.exceptions(f.failbit);}catch(conststd::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
(C++11) | holds a platform-dependent error code (class)[edit] |
(C++11) | holds a portable error code (class)[edit] |
| stream exception (public member class of std::ios_base)[edit] |