C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- è¾å ¥/è¾åºæçºµç¬¦
- std::ios_base
- std::ios_base::failure
- std::ios_base::event_callback
- std::ios_base::seekdir
- std::ios_base::event
- std::ios_base::fmtflags
- std::ios_base::iostate
- std::ios_base::iword
- std::ios_base::pword
- std::ios_base::register_callback
- std::ios_base::sync_with_stdio
- std::ios_base::Init
- std::ios_base::openmode
- std::ios_base::precision
- std::ios_base::width
- std::ios_base::imbue
- std::ios_base::getloc
- std::ios_base::xalloc
- std::ios_base::ios_base
- std::ios_base::~ios_base
- std::ios_base::flags
- std::ios_base::setf
- std::ios_base::unsetf
- C 飿 ¼æä»¶è¾å ¥/è¾åº
- std::basic_streambuf
- std::basic_filebuf
- std::basic_stringbuf
- std::strstreambuf
- std::basic_syncbuf
- std::basic_ios
- std::basic_istream
- std::basic_osyncstream
- std::basic_ostream
- std::basic_iostream
- std::basic_ifstream
- std::basic_ofstream
- std::basic_fstream
- std::basic_istringstream
- std::basic_ostringstream
- std::basic_stringstream
- std::istrstream
- std::ostrstream
- std::strstream
- std::streamoff
- std::streamsize
- std::fpos
- std::iostream_category
- std::io_errc
- std::cin, std::wcin
- std::cout, std::wcout
- std::cerr, std::wcerr
- std::clog, std::wclog
- 注é
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >è¾å ¥/è¾åºåº >std::ios_base > std::ios_base::failure
std::ios_base::failure
| å®ä¹äºå¤´æä»¶ <ios>
|
||
| class failure; |
||
ç±» std::ios_base::failure å®ä¹è¾å ¥/è¾åºåºä¸ç彿°å¨å¤±è´¥æ¶æåºçå¼å¸¸å¯¹è±¡ã
std::ios_base::failure å¯ä»¥å®ä¹ä¸º std::ios_base çæåç±»ï¼ææ¥æçä»·åè½çå¦ä¸ä¸ªç±»çåä¹è¯ï¼ typedef ï¼ã (C++17 èµ·)
|
ç»§æ¿å¾ |
(C++11 å) |
|
ç»§æ¿å¾ |
(C++11 èµ·) |
æå彿°
| (æé 彿°) |
æé å¼å¸¸å¯¹è±¡ (å ¬å¼æå彿°) |
std::ios_base::failure::failure
| explicit failure( const std::string& message ); |
(C++11 å) | |
| explicit failure( const std::string& message, Â Â Â Â Â Â Â Â Â const std::error_code& ec = std::io_errc::stream ); |
(C++11 èµ·) | |
| explicit failure( const char* message, Â Â Â Â Â Â Â Â Â const std::error_code& ec = std::io_errc::stream ); |
(C++11 èµ·) | |
以 message ä¸ºè§£éæ§å符串æé å¼å¸¸å¯¹è±¡ï¼è½å¨ä¹åç¨ what() åå¾ã
åæ°
| message | - | è§£éæ§å符串 |
ç»§æ¿èª std::system_error
æå彿°
| è¿åé误ç ( std::system_error çå
¬å¼æå彿°) | |
| [è] |
è¿åè§£éæ§å符串 ( std::system_error çèå
¬å¼æå彿°) |
ç»§æ¿èª std::runtime_error
ç»§æ¿èª std::exception
æå彿°
| [è] |
ææè¯¥å¼å¸¸å¯¹è±¡ ( std::exception çèå
¬å¼æå彿°) |
| [è] |
è¿åè§£éæ§å符串 ( std::exception çèå
¬å¼æå彿°) |
示ä¾
è¿è¡æ¤ä»£ç
#include <iostream> #include <fstream> 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" << "Explanatory string: " << e.what() << '\n' << "Error code: " << e.code() << '\n'; } }
è¾åºï¼
Caught an ios_base::failure. Explanatory string: ios_base::clear: unspecified iostream_category error Error code: iostream:1
åé
| (C++11) |
IO æµçé误ç (æä¸¾) |