| 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) | ||||
(C++11) |
| Non-member functions | ||||
| Helper classes | ||||
is_error_code_enum<std::io_errc> (C++11) |
Defined in header <ios> | ||
template<> struct is_error_code_enum<std::io_errc>:publicstd::true_type{}; | (since C++11) | |
This specialization ofstd::is_error_code_enum informs other library components that values of typestd::io_errc are enumerations that hold error codes, which makes them implicitly convertible and assignable to objects of typestd::error_code.
Contents |
value [static] | true (public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
The comparison betweene.code() andstd::io_errc::stream compiles becausestd::is_error_code_enum<std::io_errc>::value==true.
#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) | identifies a class as anerror_code enumeration(class template)[edit] |
(C++11) | holds a platform-dependent error code (class)[edit] |
(C++11) | the IO stream error codes (enum)[edit] |