std:: is_error_code_enum <std::io_errc>
|
Definiert im Header
<ios>
|
||
|
template
<>
struct is_error_code_enum < std:: io_errc > : public std:: true_type { } ; |
(seit C++11) | |
Diese Spezialisierung von std::is_error_code_enum informiert andere Bibliothekskomponenten, dass Werte des Typs std::io_errc Aufzählungen sind, die Fehlercodes enthalten, was sie implizit konvertierbar und zuweisbar zu Objekten des Typs std::error_code macht.
Inhaltsverzeichnis |
Geerbt von std:: integral_constant
Member-Konstanten
|
value
[static]
|
true
(öffentliche statische Member-Konstante) |
Member-Funktionen
|
operator bool
|
konvertiert das Objekt zu
bool
, gibt
value
zurück
(öffentliche Member-Funktion) |
|
operator()
(C++14)
|
gibt
value
zurück
(öffentliche Member-Funktion) |
Member-Typen
| Typ | Definition |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
Beispiel
Der Vergleich zwischen e. code ( ) und std::io_errc::stream kompiliert, weil std:: 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 (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"; } }
Ausgabe:
Caught an ios_base::failure. The error code is std::io_errc::stream
Siehe auch
|
(C++11)
|
identifiziert eine Klasse als eine
error_code
Enumeration
(Klassentemplate) |
|
(C++11)
|
hält einen plattformabhängigen Fehlercode
(Klasse) |
|
(C++11)
|
die IO-Stream-Fehlercodes
(Enumeration) |